Skip to content
Permalink
Browse files
Use Promise API instead of Q API
To play it safe, cordova-create still returns a Q instance, so as to
not break any callers that are relying on this implementation detail.
  • Loading branch information
raphinesse committed May 14, 2018
1 parent b00c1a4 commit 8169cad65aa86a7f471f51d77f9779f8c7f0a987
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
@@ -21,7 +21,7 @@ var fs = require('fs');
var os = require('os');
var path = require('path');

var Q = require('q');
var Promise = require('q');
var isUrl = require('is-url');
var shell = require('shelljs');
var requireFresh = require('import-fresh');
@@ -67,7 +67,7 @@ function setupEvents (externalEventEmitter) {
**/
// Returns a promise.
module.exports = function (dir, optionalId, optionalName, cfg, extEvents) {
return Q.fcall(function () {
return Promise.resolve().then(function () {
events = setupEvents(extEvents);
events.emit('verbose', 'Using detached cordova-create');

@@ -175,7 +175,7 @@ module.exports = function (dir, optionalId, optionalName, cfg, extEvents) {
}
events.emit('verbose', 'Using cordova-fetch for ' + target);
return fetch(target, tempDest, {})
.fail(function (err) {
.catch(function (err) {
events.emit('error', '\x1B[1m \x1B[31m Error from Cordova Fetch: ' + err.message);
events.emit('error', 'The template you are trying to use is invalid.' +
' Make sure you follow the template guide found here https://cordova.apache.org/docs/en/latest/guide/cli/template.html.' +
@@ -98,14 +98,14 @@ var configNPM = {
describe('cordova create checks for valid-identifier', function () {
it('should reject reserved words from start of id', function () {
return create('projectPath', 'int.bob', 'appName', {}, events)
.fail(function (err) {
.catch(function (err) {
expect(err.message).toBe('App id contains a reserved word, or is not a valid identifier.');
});
}, 60000);

it('should reject reserved words from end of id', function () {
return create('projectPath', 'bob.class', 'appName', {}, events)
.fail(function (err) {
.catch(function (err) {
expect(err.message).toBe('App id contains a reserved word, or is not a valid identifier.');
});
}, 60000);
@@ -369,7 +369,7 @@ describe('create end-to-end', function () {
};
return create(project, appId, appName, config, events)
.then(checkSymWWW)
.fail(function (err) {
.catch(function (err) {
if (process.platform.slice(0, 3) === 'win') {
// Allow symlink error if not in admin mode
expect(err.message).toBe('Symlinks on Windows require Administrator privileges');
@@ -425,7 +425,7 @@ describe('create end-to-end', function () {
};
return create(project, appId, appName, config, events)
.then(checkSymSubDir)
.fail(function (err) {
.catch(function (err) {
if (process.platform.slice(0, 3) === 'win') {
// Allow symlink error if not in admin mode
expect(err.message).toBe('Symlinks on Windows require Administrator privileges');
@@ -471,7 +471,7 @@ describe('create end-to-end', function () {
};
return create(project, appId, appName, config, events)
.then(checkSymNoConfig)
.fail(function (err) {
.catch(function (err) {
if (process.platform.slice(0, 3) === 'win') {
// Allow symlink error if not in admin mode
expect(err.message).toBe('Symlinks on Windows require Administrator privileges');

0 comments on commit 8169cad

Please sign in to comment.