From b03d3bae19badda0578cb60b5e14002d50399823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Fri, 14 Jun 2019 10:06:25 +0900 Subject: [PATCH 1/2] Remove Q for Native Promise --- bin/lib/update.js | 18 ++++++++++-------- bin/update | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) mode change 100644 => 100755 bin/update 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..ffb956a2 --- 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); }); From f3f16939c5a64ea392883530046ddb6d4a04ff3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Tue, 18 Jun 2019 13:37:40 +0900 Subject: [PATCH 2/2] Update bin/update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Raphael von der GrĂ¼n --- bin/update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/update b/bin/update index ffb956a2..29f4bfe6 100755 --- a/bin/update +++ b/bin/update @@ -26,7 +26,7 @@ if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > } else { update.run(process.argv).then(() => { console.log('Successfully updated browser project.'); - }, (err) => { + }, err => { console.error('Update failed due to', err); process.exit(2); });