You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by dp...@apache.org on 2018/06/05 23:20:18 UTC
[cordova-fetch] branch master updated: Isolate Q usage to prepare
later removal
This is an automated email from the ASF dual-hosted git repository.
dpogue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-fetch.git
The following commit(s) were added to refs/heads/master by this push:
new 19b2be4 Isolate Q usage to prepare later removal
19b2be4 is described below
commit 19b2be4e722e85e80707e1fa175bcc5eebec573e
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Tue Jun 5 09:48:19 2018 +0200
Isolate Q usage to prepare later removal
---
index.js | 22 ++++++++++++----------
spec/fetch-unit.spec.js | 5 ++---
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/index.js b/index.js
index 8bb6326..e2ab4ee 100644
--- a/index.js
+++ b/index.js
@@ -59,7 +59,7 @@ module.exports = function (target, dest, opts) {
if (!fs.existsSync(nodeModulesDir)) {
shell.mkdir('-p', nodeModulesDir);
}
- } else return Q.reject(new CordovaError('Need to supply a target and destination'));
+ } else throw new CordovaError('Need to supply a target and destination');
// set the directory where npm install will be run
opts.cwd = dest;
@@ -101,8 +101,8 @@ module.exports = function (target, dest, opts) {
var id = getJsonDiff(tree1, tree2) || trimID(target);
return module.exports.getPath(id, nodeModulesDir, target);
})
- .fail(function (err) {
- return Q.reject(new CordovaError(err));
+ .catch(function (err) {
+ throw new CordovaError(err);
});
};
@@ -254,10 +254,12 @@ function searchDirForTarget (dest, target) {
*/
function isNpmInstalled () {
- if (!shell.which('npm')) {
- return Q.reject(new CordovaError('"npm" command line tool is not installed: make sure it is accessible on your PATH.'));
- }
- return Q();
+ return Q.Promise(function (resolve) {
+ if (!shell.which('npm')) {
+ throw new CordovaError('"npm" command line tool is not installed: make sure it is accessible on your PATH.');
+ }
+ resolve();
+ });
}
module.exports.isNpmInstalled = isNpmInstalled;
@@ -281,7 +283,7 @@ module.exports.uninstall = function (target, dest, opts) {
if (dest && target) {
// add target to fetchArgs Array
fetchArgs.push(target);
- } else return Q.reject(new CordovaError('Need to supply a target and destination'));
+ } else throw new CordovaError('Need to supply a target and destination');
// set the directory where npm uninstall will be run
opts.cwd = dest;
@@ -304,7 +306,7 @@ module.exports.uninstall = function (target, dest, opts) {
}
return res;
})
- .fail(function (err) {
- return Q.reject(new CordovaError(err));
+ .catch(function (err) {
+ throw new CordovaError(err);
});
};
diff --git a/spec/fetch-unit.spec.js b/spec/fetch-unit.spec.js
index c1c1f70..81ec9d1 100644
--- a/spec/fetch-unit.spec.js
+++ b/spec/fetch-unit.spec.js
@@ -19,15 +19,14 @@
var fetch = require('../index.js');
var shell = require('shelljs');
var fs = require('fs');
-var Q = require('q');
var superspawn = require('cordova-common').superspawn;
describe('unit tests for index.js', function () {
beforeEach(function () {
spyOn(superspawn, 'spawn').and.returnValue(true);
spyOn(shell, 'mkdir').and.returnValue(true);
- spyOn(shell, 'which').and.returnValue(Q());
- spyOn(fetch, 'isNpmInstalled').and.returnValue(Q());
+ spyOn(shell, 'which').and.returnValue(Promise.resolve());
+ spyOn(fetch, 'isNpmInstalled').and.returnValue(Promise.resolve());
spyOn(fetch, 'getPath').and.returnValue('some/path');
spyOn(fs, 'existsSync').and.returnValue(false);
});
--
To stop receiving notification emails like this one, please contact
dpogue@apache.org.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org