summaryrefslogtreecommitdiffstats
path: root/node_modules/nodemon/lib/cli/index.js
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/nodemon/lib/cli/index.js
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/nodemon/lib/cli/index.js')
-rw-r--r--node_modules/nodemon/lib/cli/index.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/node_modules/nodemon/lib/cli/index.js b/node_modules/nodemon/lib/cli/index.js
new file mode 100644
index 0000000..bf9e809
--- /dev/null
+++ b/node_modules/nodemon/lib/cli/index.js
@@ -0,0 +1,49 @@
+var parse = require('./parse');
+
+/**
+ * Converts a string to command line args, in particular
+ * groups together quoted values.
+ * This is a utility function to allow calling nodemon as a required
+ * library, but with the CLI args passed in (instead of an object).
+ *
+ * @param {String} string
+ * @return {Array}
+ */
+function stringToArgs(string) {
+ var args = [];
+
+ var parts = string.split(' ');
+ var length = parts.length;
+ var i = 0;
+ var open = false;
+ var grouped = '';
+ var lead = '';
+
+ for (; i < length; i++) {
+ lead = parts[i].substring(0, 1);
+ if (lead === '"' || lead === '\'') {
+ open = lead;
+ grouped = parts[i].substring(1);
+ } else if (open && parts[i].slice(-1) === open) {
+ open = false;
+ grouped += ' ' + parts[i].slice(0, -1);
+ args.push(grouped);
+ } else if (open) {
+ grouped += ' ' + parts[i];
+ } else {
+ args.push(parts[i]);
+ }
+ }
+
+ return args;
+}
+
+module.exports = {
+ parse: function (argv) {
+ if (typeof argv === 'string') {
+ argv = stringToArgs(argv);
+ }
+
+ return parse(argv);
+ },
+}; \ No newline at end of file