diff --git a/packager/react-packager/__mocks__/bluebird.js b/packager/react-packager/__mocks__/bluebird.js deleted file mode 100644 index 9ac6e14b6..000000000 --- a/packager/react-packager/__mocks__/bluebird.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -jest.autoMockOff(); -module.exports = require.requireActual('bluebird'); -jest.autoMockOn(); diff --git a/packager/react-packager/src/AssetServer/__tests__/AssetServer-test.js b/packager/react-packager/src/AssetServer/__tests__/AssetServer-test.js index c6acc6a84..95916c9ea 100644 --- a/packager/react-packager/src/AssetServer/__tests__/AssetServer-test.js +++ b/packager/react-packager/src/AssetServer/__tests__/AssetServer-test.js @@ -8,7 +8,7 @@ jest .mock('crypto') .mock('fs'); -var Promise = require('bluebird'); +var Promise = require('promise'); describe('AssetServer', function() { var AssetServer; diff --git a/packager/react-packager/src/AssetServer/index.js b/packager/react-packager/src/AssetServer/index.js index 0479afc2a..2cd365fdc 100644 --- a/packager/react-packager/src/AssetServer/index.js +++ b/packager/react-packager/src/AssetServer/index.js @@ -11,13 +11,13 @@ var declareOpts = require('../lib/declareOpts'); var getAssetDataFromName = require('../lib/getAssetDataFromName'); var path = require('path'); -var Promise = require('bluebird'); +var Promise = require('promise'); var fs = require('fs'); var crypto = require('crypto'); -var stat = Promise.promisify(fs.stat); -var readDir = Promise.promisify(fs.readdir); -var readFile = Promise.promisify(fs.readFile); +var stat = Promise.denodeify(fs.stat); +var readDir = Promise.denodeify(fs.readdir); +var readFile = Promise.denodeify(fs.readFile); module.exports = AssetServer; @@ -56,12 +56,15 @@ AssetServer.prototype._getAssetRecord = function(assetPath) { this._roots, path.dirname(assetPath) ).then(function(dir) { - return [ + return Promise.all([ dir, readDir(dir), - ]; - }).spread(function(dir, files) { + ]); + }).then(function(res) { + var dir = res[0]; + var files = res[1]; var assetData = getAssetDataFromName(filename); + var map = buildAssetMap(dir, files); var record = map[assetData.assetName]; @@ -114,21 +117,23 @@ AssetServer.prototype.getAssetData = function(assetPath) { }; function findRoot(roots, dir) { - return Promise.some( + return Promise.all( roots.map(function(root) { var absPath = path.join(root, dir); return stat(absPath).then(function(fstat) { - if (!fstat.isDirectory()) { - throw new Error('Looking for dirs'); - } - fstat._path = absPath; - return fstat; + return {path: absPath, isDirectory: fstat.isDirectory()}; + }, function (err) { + return {path: absPath, isDirectory: false}; }); - }), - 1 - ).spread( - function(fstat) { - return fstat._path; + }) + ).then( + function(stats) { + for (var i = 0; i < stats.length; i++) { + if (stats[i].isDirectory) { + return stats[i].path; + } + } + throw new Error('Could not find any directories'); } ); } diff --git a/packager/react-packager/src/DependencyResolver/AssetModule.js b/packager/react-packager/src/DependencyResolver/AssetModule.js index 431e6d01c..bfe4b6f88 100644 --- a/packager/react-packager/src/DependencyResolver/AssetModule.js +++ b/packager/react-packager/src/DependencyResolver/AssetModule.js @@ -1,7 +1,7 @@ 'use strict'; const Module = require('./Module'); -const Promise = require('bluebird'); +const Promise = require('promise'); const getAssetDataFromName = require('../lib/getAssetDataFromName'); class AssetModule extends Module { diff --git a/packager/react-packager/src/DependencyResolver/AssetModule_DEPRECATED.js b/packager/react-packager/src/DependencyResolver/AssetModule_DEPRECATED.js index 7a25c5905..fd4cb7081 100644 --- a/packager/react-packager/src/DependencyResolver/AssetModule_DEPRECATED.js +++ b/packager/react-packager/src/DependencyResolver/AssetModule_DEPRECATED.js @@ -1,7 +1,7 @@ 'use strict'; const Module = require('./Module'); -const Promise = require('bluebird'); +const Promise = require('promise'); const getAssetDataFromName = require('../lib/getAssetDataFromName'); class AssetModule_DEPRECATED extends Module { diff --git a/packager/react-packager/src/DependencyResolver/DependencyGraph/index.js b/packager/react-packager/src/DependencyResolver/DependencyGraph/index.js index 5bb630849..63ba7875e 100644 --- a/packager/react-packager/src/DependencyResolver/DependencyGraph/index.js +++ b/packager/react-packager/src/DependencyResolver/DependencyGraph/index.js @@ -17,7 +17,7 @@ const isAbsolutePath = require('absolute-path'); const debug = require('debug')('DependencyGraph'); const getAssetDataFromName = require('../../lib/getAssetDataFromName'); const util = require('util'); -const Promise = require('bluebird'); +const Promise = require('promise'); const _ = require('underscore'); const validateOpts = declareOpts({ diff --git a/packager/react-packager/src/DependencyResolver/Module.js b/packager/react-packager/src/DependencyResolver/Module.js index d0be012ba..3ae9354d3 100644 --- a/packager/react-packager/src/DependencyResolver/Module.js +++ b/packager/react-packager/src/DependencyResolver/Module.js @@ -1,6 +1,6 @@ 'use strict'; -const Promise = require('bluebird'); +const Promise = require('promise'); const docblock = require('./DependencyGraph/docblock'); const isAbsolutePath = require('absolute-path'); const path = require('path'); diff --git a/packager/react-packager/src/DependencyResolver/__tests__/HasteDependencyResolver-test.js b/packager/react-packager/src/DependencyResolver/__tests__/HasteDependencyResolver-test.js index f97828869..da159b5e9 100644 --- a/packager/react-packager/src/DependencyResolver/__tests__/HasteDependencyResolver-test.js +++ b/packager/react-packager/src/DependencyResolver/__tests__/HasteDependencyResolver-test.js @@ -14,7 +14,7 @@ jest.dontMock('../') jest.mock('path'); -var Promise = require('bluebird'); +var Promise = require('promise'); describe('HasteDependencyResolver', function() { var HasteDependencyResolver; diff --git a/packager/react-packager/src/DependencyResolver/fastfs.js b/packager/react-packager/src/DependencyResolver/fastfs.js index fc09ea8b3..0053b14e3 100644 --- a/packager/react-packager/src/DependencyResolver/fastfs.js +++ b/packager/react-packager/src/DependencyResolver/fastfs.js @@ -1,6 +1,6 @@ 'use strict'; -const Promise = require('bluebird'); +const Promise = require('promise'); const {EventEmitter} = require('events'); const _ = require('underscore'); @@ -8,9 +8,9 @@ const debug = require('debug')('DependencyGraph'); const fs = require('fs'); const path = require('path'); -const readDir = Promise.promisify(fs.readdir); -const readFile = Promise.promisify(fs.readFile); -const stat = Promise.promisify(fs.stat); +const readDir = Promise.denodeify(fs.readdir); +const readFile = Promise.denodeify(fs.readFile); +const stat = Promise.denodeify(fs.stat); const hasOwn = Object.prototype.hasOwnProperty; class Fastfs extends EventEmitter { diff --git a/packager/react-packager/src/DependencyResolver/index.js b/packager/react-packager/src/DependencyResolver/index.js index bfc4e9432..0ddf5c3cc 100644 --- a/packager/react-packager/src/DependencyResolver/index.js +++ b/packager/react-packager/src/DependencyResolver/index.js @@ -12,7 +12,7 @@ var path = require('path'); var DependencyGraph = require('./DependencyGraph'); var replacePatterns = require('./replacePatterns'); var declareOpts = require('../lib/declareOpts'); -var Promise = require('bluebird'); +var Promise = require('promise'); var validateOpts = declareOpts({ projectRoots: { diff --git a/packager/react-packager/src/FileWatcher/index.js b/packager/react-packager/src/FileWatcher/index.js index cd1a28e55..aac211ad2 100644 --- a/packager/react-packager/src/FileWatcher/index.js +++ b/packager/react-packager/src/FileWatcher/index.js @@ -10,7 +10,7 @@ var EventEmitter = require('events').EventEmitter; var sane = require('sane'); -var Promise = require('bluebird'); +var Promise = require('promise'); var util = require('util'); var exec = require('child_process').exec; @@ -57,7 +57,7 @@ util.inherits(FileWatcher, EventEmitter); FileWatcher.prototype.end = function() { return this._loading.then(function(watchers) { watchers.forEach(function(watcher) { - return Promise.promisify(watcher.close, watcher)(); + return Promise.denodeify(watcher.close).call(watcher); }); }); }; diff --git a/packager/react-packager/src/JSTransformer/Cache.js b/packager/react-packager/src/JSTransformer/Cache.js index 584077b6c..aee8d4f21 100644 --- a/packager/react-packager/src/JSTransformer/Cache.js +++ b/packager/react-packager/src/JSTransformer/Cache.js @@ -14,7 +14,7 @@ var declareOpts = require('../lib/declareOpts'); var fs = require('fs'); var isAbsolutePath = require('absolute-path'); var path = require('path'); -var Promise = require('bluebird'); +var Promise = require('promise'); var tmpdir = require('os').tmpDir(); var version = require('../../../../package.json').version; @@ -74,11 +74,13 @@ Cache.prototype.get = function(filepath, loaderCb) { Cache.prototype._set = function(filepath, loaderPromise) { this._data[filepath] = loaderPromise.then(function(data) { - return [ + return Promise.all([ data, - Promise.promisify(fs.stat)(filepath) - ]; - }).spread(function(data, stat) { + Promise.denodeify(fs.stat)(filepath) + ]); + }).then(function(ref) { + var data = ref[0]; + var stat = ref[1]; this._persistEventually(); return { data: data, @@ -113,7 +115,7 @@ Cache.prototype._persistCache = function() { Object.keys(data).forEach(function(key, i) { json[key] = values[i]; }); - return Promise.promisify(fs.writeFile)(cacheFilepath, JSON.stringify(json)); + return Promise.denodeify(fs.writeFile)(cacheFilepath, JSON.stringify(json)); }) .then(function() { this._persisting = null; diff --git a/packager/react-packager/src/JSTransformer/__tests__/Cache-test.js b/packager/react-packager/src/JSTransformer/__tests__/Cache-test.js index f91490ba0..3877b3dd5 100644 --- a/packager/react-packager/src/JSTransformer/__tests__/Cache-test.js +++ b/packager/react-packager/src/JSTransformer/__tests__/Cache-test.js @@ -17,7 +17,7 @@ jest .mock('os') .mock('fs'); -var Promise = require('bluebird'); +var Promise = require('promise'); describe('JSTransformer Cache', function() { var Cache; diff --git a/packager/react-packager/src/JSTransformer/index.js b/packager/react-packager/src/JSTransformer/index.js index 513d4394e..7c20e10ed 100644 --- a/packager/react-packager/src/JSTransformer/index.js +++ b/packager/react-packager/src/JSTransformer/index.js @@ -9,14 +9,14 @@ 'use strict'; var fs = require('fs'); -var Promise = require('bluebird'); +var Promise = require('promise'); var Cache = require('./Cache'); var workerFarm = require('worker-farm'); var declareOpts = require('../lib/declareOpts'); var util = require('util'); var ModuleTransport = require('../lib/ModuleTransport'); -var readFile = Promise.promisify(fs.readFile); +var readFile = Promise.denodeify(fs.readFile); module.exports = Transformer; Transformer.TransformError = TransformError; @@ -69,7 +69,7 @@ function Transformer(options) { options.transformModulePath ); - this._transform = Promise.promisify(this._workers); + this._transform = Promise.denodeify(this._workers); } } diff --git a/packager/react-packager/src/Packager/__tests__/Packager-test.js b/packager/react-packager/src/Packager/__tests__/Packager-test.js index aaa8963c2..216e9009f 100644 --- a/packager/react-packager/src/Packager/__tests__/Packager-test.js +++ b/packager/react-packager/src/Packager/__tests__/Packager-test.js @@ -17,7 +17,7 @@ jest jest.mock('fs'); -var Promise = require('bluebird'); +var Promise = require('promise'); describe('Packager', function() { var getDependencies; diff --git a/packager/react-packager/src/Packager/index.js b/packager/react-packager/src/Packager/index.js index 04404ff19..3c6d1a2fc 100644 --- a/packager/react-packager/src/Packager/index.js +++ b/packager/react-packager/src/Packager/index.js @@ -11,7 +11,7 @@ var assert = require('assert'); var fs = require('fs'); var path = require('path'); -var Promise = require('bluebird'); +var Promise = require('promise'); var Transformer = require('../JSTransformer'); var DependencyResolver = require('../DependencyResolver'); var Package = require('./Package'); @@ -20,8 +20,8 @@ var ModuleTransport = require('../lib/ModuleTransport'); var declareOpts = require('../lib/declareOpts'); var imageSize = require('image-size'); -var sizeOf = Promise.promisify(imageSize); -var readFile = Promise.promisify(fs.readFile); +var sizeOf = Promise.denodeify(imageSize); +var readFile = Promise.denodeify(fs.readFile); var validateOpts = declareOpts({ projectRoots: { @@ -207,7 +207,9 @@ Packager.prototype.generateAssetModule = function(ppackage, module) { return Promise.all([ sizeOf(module.path), this._assetServer.getAssetData(relPath), - ]).spread(function(dimensions, assetData) { + ]).then(function(res) { + var dimensions = res[0]; + var assetData = res[1]; var img = { __packager_asset: true, fileSystemLocation: path.dirname(module.path), diff --git a/packager/react-packager/src/Server/__tests__/Server-test.js b/packager/react-packager/src/Server/__tests__/Server-test.js index e4e7b5088..32c9060a4 100644 --- a/packager/react-packager/src/Server/__tests__/Server-test.js +++ b/packager/react-packager/src/Server/__tests__/Server-test.js @@ -20,7 +20,7 @@ jest.setMock('worker-farm', function() { return function() {}; }) .setMock('uglify-js') .dontMock('../'); -var Promise = require('bluebird'); +var Promise = require('promise'); describe('processRequest', function() { var server; diff --git a/packager/react-packager/src/Server/index.js b/packager/react-packager/src/Server/index.js index 914075fea..1d2140ef5 100644 --- a/packager/react-packager/src/Server/index.js +++ b/packager/react-packager/src/Server/index.js @@ -15,7 +15,7 @@ var FileWatcher = require('../FileWatcher'); var Packager = require('../Packager'); var Activity = require('../Activity'); var AssetServer = require('../AssetServer'); -var Promise = require('bluebird'); +var Promise = require('promise'); var _ = require('underscore'); var exec = require('child_process').exec; var fs = require('fs');