You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2018/12/19 00:52:36 UTC
[cordova-electron] branch master updated: Cleanup Bin Files (#6)
This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-electron.git
The following commit(s) were added to refs/heads/master by this push:
new 3af4318 Cleanup Bin Files (#6)
3af4318 is described below
commit 3af43187b8a032aed980b7d272e32267a68dfb8c
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Wed Dec 19 09:52:31 2018 +0900
Cleanup Bin Files (#6)
---
bin/templates/cordova/build | 28 +++++++++++++---------------
bin/templates/cordova/clean | 29 +++++++++++++----------------
bin/templates/cordova/lib/build.js | 10 +++++++---
bin/templates/cordova/lib/clean.js | 5 +++++
bin/templates/cordova/lib/run.js | 8 ++++++++
bin/templates/cordova/run | 29 +++++++++++++----------------
6 files changed, 59 insertions(+), 50 deletions(-)
diff --git a/bin/templates/cordova/build b/bin/templates/cordova/build
index d127636..5ad92d4 100755
--- a/bin/templates/cordova/build
+++ b/bin/templates/cordova/build
@@ -19,21 +19,19 @@
under the License.
*/
+const argv = require('nopt')({
+ help: Boolean
+}, {
+ help: ['/?', '-h', 'help', '-help', '--help', '/help']
+});
+
+argv.binPath = process.argv[1];
+
const build = require('./lib/build');
-const args = process.argv;
-
-// provide help
-if (
- args[2] === '--help' ||
- args[2] === '/?' ||
- args[2] === '-h' ||
- args[2] === '/h' ||
- args[2] === 'help' ||
- args[2] === '-help' ||
- args[2] === '/help'
-) {
- build.help();
+
+if (argv.help) {
+ build.help(argv);
process.exit(0);
-} else {
- build.run();
}
+
+build.run(argv);
diff --git a/bin/templates/cordova/clean b/bin/templates/cordova/clean
old mode 100644
new mode 100755
index 43228c2..6115685
--- a/bin/templates/cordova/clean
+++ b/bin/templates/cordova/clean
@@ -19,22 +19,19 @@
under the License.
*/
-const path = require('path');
+const argv = require('nopt')({
+ help: Boolean
+}, {
+ help: ['/?', '-h', 'help', '-help', '--help', '/help']
+});
+
+argv.binPath = process.argv[1];
+
const clean = require('./lib/clean');
-const args = process.argv;
-
-// Support basic help commands
-if (
- args.length > 2 ||
- args[2] === '--help' ||
- args[2] === '/?' ||
- args[2] === '-h' ||
- args[2] === 'help' ||
- args[2] === '-help' ||
- args[2] === '/help'
-) {
- console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'clean')));
+
+if (argv.help) {
+ clean.help(argv);
process.exit(0);
-} else {
- clean.run();
}
+
+clean.run(argv);
diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js
index 5a3f6ec..190c3e0 100644
--- a/bin/templates/cordova/lib/build.js
+++ b/bin/templates/cordova/lib/build.js
@@ -294,7 +294,11 @@ module.exports.run = (buildOptions, api) => require('./check_reqs')
console.log(error);
});
-module.exports.help = () => {
- console.log('Usage: cordova build electron');
- console.log('Packages your app for distribution, or running locally.');
+module.exports.help = (argv) => {
+ const binPath = path.relative(process.cwd(), argv.binPath);
+ console.log(`Usage: ${binPath} [flags]
+Flags:
+ '--debug': will build project in debug mode (default)
+ '--release': will build project for release
+ '--nobuild': will skip build process (useful when using run command)`);
};
diff --git a/bin/templates/cordova/lib/clean.js b/bin/templates/cordova/lib/clean.js
index 9bbd86f..a1c802c 100644
--- a/bin/templates/cordova/lib/clean.js
+++ b/bin/templates/cordova/lib/clean.js
@@ -44,3 +44,8 @@ module.exports.cleanProject = () => {
console.log('lib/clean will soon only export a `run` command, please update to not call `cleanProject`.');
return module.exports.run();
};
+
+module.exports.help = (argv) => {
+ const binPath = path.relative(process.cwd(), argv.binPath);
+ console.log(`Usage: ${binPath}`);
+};
diff --git a/bin/templates/cordova/lib/run.js b/bin/templates/cordova/lib/run.js
index fb817c0..4d03f4c 100644
--- a/bin/templates/cordova/lib/run.js
+++ b/bin/templates/cordova/lib/run.js
@@ -19,6 +19,7 @@
const electron = require('electron');
const proc = require('child_process');
+const path = require('path');
module.exports.run = (args) => {
// console.log("runOptions : ", args);
@@ -28,3 +29,10 @@ module.exports.run = (args) => {
process.exit(code);
});
};
+
+module.exports.help = (argv) => {
+ const binPath = path.relative(process.cwd(), argv.binPath);
+ console.log(`Usage: ${binPath} [flags]
+Flags:
+ '--nobuild': will skip build process (useful when using run command)`);
+};
diff --git a/bin/templates/cordova/run b/bin/templates/cordova/run
index 44f9e2d..bdbfc50 100755
--- a/bin/templates/cordova/run
+++ b/bin/templates/cordova/run
@@ -19,24 +19,21 @@
under the License.
*/
-const nopt = require('nopt');
-const runForrest = require('./lib/run');
-
-const args = process.argv;
+const argv = require('nopt')({
+ help: Boolean,
+ target: String,
+ port: Number
+}, {
+ help: ['/?', '-h', 'help', '-help', '--help', '/help']
+});
-start(args);
+argv.binPath = process.argv[1];
-function start (argv) {
- var args = nopt({ 'help': Boolean, 'target': String, 'port': Number }, { 'help': ['/?', '-h', 'help', '-help', '/help'] }, argv);
- if (args.help) {
- help();
- } else {
- return runForrest.run(args);
- }
-}
+const runForrest = require('./lib/run');
-function help () {
- console.log('\nUsage: run');
- console.log(''); // TODO ?
+if (argv.help) {
+ runForrest.help(argv);
process.exit(0);
}
+
+runForrest.run(argv);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org