diff --git a/bin/lib/update.js b/bin/lib/update.js index 62e37e13..633b385a 100644 --- a/bin/lib/update.js +++ b/bin/lib/update.js @@ -17,10 +17,10 @@ under the License. */ -var Q = require('q'); var create = require('./create'); var fs = require('fs'); var shell = require('shelljs'); +const { CordovaError } = require('cordova-common'); module.exports.help = function () { console.log('WARNING : Make sure to back up your project before updating!'); @@ -32,15 +32,17 @@ module.exports.help = function () { module.exports.run = function (argv) { var projectPath = argv[2]; + + // If the specified project path is not valid then reject promise. if (!fs.existsSync(projectPath)) { - // if specified project path is not valid then reject promise - Q.reject('Browser platform does not exist here: ' + projectPath); + return Promise.reject(new CordovaError(`Browser platform does not exist here: ${projectPath}`)); } - return Q().then(function () { - console.log('Removing existing browser platform.'); - shellfatal(shell.rm, '-rf', projectPath); - create.createProject(projectPath); - }); + + console.log('Removing existing browser platform.'); + shellfatal(shell.rm, '-rf', projectPath); + + // Create Project returns a resolved promise. + return create.createProject(projectPath); }; function shellfatal (shellFunc) { diff --git a/bin/update b/bin/update old mode 100644 new mode 100755 index eb515b70..29f4bfe6 --- a/bin/update +++ b/bin/update @@ -24,9 +24,9 @@ var update = require('./lib/update'); if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) { update.help(); } else { - update.run(process.argv).done(function () { + update.run(process.argv).then(() => { console.log('Successfully updated browser project.'); - }, function (err) { + }, err => { console.error('Update failed due to', err); process.exit(2); });