Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Q for Native Promise #78

Merged
merged 2 commits into from Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions bin/lib/update.js
Expand Up @@ -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!');
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions bin/update 100644 → 100755
Expand Up @@ -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);
});
Expand Down