diff --git a/packages/moon-cli/dist/moon-cli.js b/packages/moon-cli/dist/moon-cli.js index 7904b748..63d9d9b5 100644 --- a/packages/moon-cli/dist/moon-cli.js +++ b/packages/moon-cli/dist/moon-cli.js @@ -17,7 +17,7 @@ var exec = require("child_process").exec; var parameterRE = /<\w+>/g; - var optionRE = /\[\w+\]|--?\w+/g; + var optionRE = /(?:^|\s)(?:\[\w+\]|--?\w+)/g; var help = { version: { usage: "moon version", diff --git a/packages/moon-cli/dist/moon-cli.min.js b/packages/moon-cli/dist/moon-cli.min.js index e31ed2e6..d264e4a2 100755 --- a/packages/moon-cli/dist/moon-cli.min.js +++ b/packages/moon-cli/dist/moon-cli.min.js @@ -5,4 +5,4 @@ * Released under the MIT License * https://kbrsh.github.io/moon */ -!function(){"use strict";var o,c,s=require("fs"),m=require("path"),n=require("https"),a=require("child_process").exec,t=/<\w+>/g,r=/\[\w+\]|--?\w+/g,e={version:{usage:"moon version",description:"output Moon CLI version"},help:{usage:"moon help ",description:"output help message for command",parameters:{"":"name of Moon CLI command"}},create:{usage:"moon create [options]",description:"create application in new directory",parameters:{"":"name of application and directory"},options:{"-t, --template /":"GitHub repository to use as template"}}};function i(n){var e=Object.keys(n),t=Math.max.apply(null,e.map(function(e){return e.length}));return e.map(function(e){return"\t"+e+" ".repeat(t-e.length+3)+n[e]}).join("\n")}function l(e,n){console.log("\x1b[34m"+e+"\x1b[0m "+n)}function p(e){console.log(function(e){return e.replace(t,"\x1b[33m$&\x1b[0m").replace(r,"\x1b[36m$&\x1b[0m")}(e))}function u(e){console.log("\x1b[31merror\x1b[0m "+e)}function d(e,n,t){var o=e.indexOf(n);if(-1===o)return e;var a=e.slice(0,o),r=d(e.slice(o+n.length),n,t),i=Buffer.from(t);return Buffer.concat([a,i,r],a.length+i.length+r.length)}function f(e){var n=m.join(__dirname,"moon-template.tar.gz"),t=s.createWriteStream(n);e.on("data",function(e){t.write(e)}),e.on("end",function(){t.end(),l("download",o),function(n){var t=m.join(process.cwd(),c);a("mkdir "+t,function(e){if(e)throw e;a("tar -xzf "+n+" -C "+t+" --strip=1",function(e){if(e)throw e;l("install",t),function(n,t){s.unlink(n,function(e){if(e)throw e;l("clean",n),function e(n,t){var o=s.readdirSync(n);for(var a=0;a [options]\n\nCommands:\n"+i(M))}break;case"create":c=g[0],o=w["-t"]||w["--template"]||"kbrsh/moon-template",void 0!==c&&0!==c.length||u("Invalid or unknown name.\n\nAttempted to create an application.\n\nReceived an invalid or unknown name.\n\nExpected a valid name. Run \x1b[35mmoon help create\x1b[0m to see usage information."),!0===o&&u("Invalid or unknown template.\n\nAttempted to create an application.\n\nReceived an invalid or unknown template.\n\nExpected a valid template. Run \x1b[35mmoon help create\x1b[0m to see usage information.");var I={method:"GET",host:"api.github.com",path:"/repos/"+o+"/tarball/master",headers:{"User-Agent":"Moon"}};l("Moon","Generating application"),n.get(I,function(e){300<=e.statusCode&&e.statusCode<400&&void 0!==e.headers.location?n.get(e.headers.location,function(e){f(e)}):f(e)});break;default:u("Unrecognized command.\n\nAttempted to execute a command.\n\nReceived a command that does not exist:\n\t"+h+"\n\nExpected a valid command. Run \x1b[35mmoon help\x1b[0m to see valid commands.")}}(); \ No newline at end of file +!function(){"use strict";var o,c,s=require("fs"),m=require("path"),n=require("https"),a=require("child_process").exec,t=/<\w+>/g,r=/(?:^|\s)(?:\[\w+\]|--?\w+)/g,e={version:{usage:"moon version",description:"output Moon CLI version"},help:{usage:"moon help ",description:"output help message for command",parameters:{"":"name of Moon CLI command"}},create:{usage:"moon create [options]",description:"create application in new directory",parameters:{"":"name of application and directory"},options:{"-t, --template /":"GitHub repository to use as template"}}};function i(n){var e=Object.keys(n),t=Math.max.apply(null,e.map(function(e){return e.length}));return e.map(function(e){return"\t"+e+" ".repeat(t-e.length+3)+n[e]}).join("\n")}function l(e,n){console.log("\x1b[34m"+e+"\x1b[0m "+n)}function p(e){console.log(function(e){return e.replace(t,"\x1b[33m$&\x1b[0m").replace(r,"\x1b[36m$&\x1b[0m")}(e))}function u(e){console.log("\x1b[31merror\x1b[0m "+e)}function d(e,n,t){var o=e.indexOf(n);if(-1===o)return e;var a=e.slice(0,o),r=d(e.slice(o+n.length),n,t),i=Buffer.from(t);return Buffer.concat([a,i,r],a.length+i.length+r.length)}function f(e){var n=m.join(__dirname,"moon-template.tar.gz"),t=s.createWriteStream(n);e.on("data",function(e){t.write(e)}),e.on("end",function(){t.end(),l("download",o),function(n){var t=m.join(process.cwd(),c);a("mkdir "+t,function(e){if(e)throw e;a("tar -xzf "+n+" -C "+t+" --strip=1",function(e){if(e)throw e;l("install",t),function(n,t){s.unlink(n,function(e){if(e)throw e;l("clean",n),function e(n,t){var o=s.readdirSync(n);for(var a=0;a [options]\n\nCommands:\n"+i(M))}break;case"create":c=g[0],o=w["-t"]||w["--template"]||"kbrsh/moon-template",void 0!==c&&0!==c.length||u("Invalid or unknown name.\n\nAttempted to create an application.\n\nReceived an invalid or unknown name.\n\nExpected a valid name. Run \x1b[35mmoon help create\x1b[0m to see usage information."),!0===o&&u("Invalid or unknown template.\n\nAttempted to create an application.\n\nReceived an invalid or unknown template.\n\nExpected a valid template. Run \x1b[35mmoon help create\x1b[0m to see usage information.");var I={method:"GET",host:"api.github.com",path:"/repos/"+o+"/tarball/master",headers:{"User-Agent":"Moon"}};l("Moon","Generating application"),n.get(I,function(e){300<=e.statusCode&&e.statusCode<400&&void 0!==e.headers.location?n.get(e.headers.location,function(e){f(e)}):f(e)});break;default:u("Unrecognized command.\n\nAttempted to execute a command.\n\nReceived a command that does not exist:\n\t"+h+"\n\nExpected a valid command. Run \x1b[35mmoon help\x1b[0m to see valid commands.")}}(); \ No newline at end of file diff --git a/packages/moon-cli/src/index.js b/packages/moon-cli/src/index.js index 08823fe6..ee416157 100755 --- a/packages/moon-cli/src/index.js +++ b/packages/moon-cli/src/index.js @@ -4,7 +4,7 @@ const https = require("https"); const exec = require("child_process").exec; const parameterRE = /<\w+>/g; -const optionRE = /\[\w+\]|--?\w+/g; +const optionRE = /(?:^|\s)(?:\[\w+\]|--?\w+)/g; const help = { version: {