diff --git a/packages/generator-electrode/component-add/index.js b/packages/generator-electrode/component-add/index.js index 0df30fa7b5..28cc2076fd 100644 --- a/packages/generator-electrode/component-add/index.js +++ b/packages/generator-electrode/component-add/index.js @@ -176,12 +176,14 @@ module.exports = class extends Generator { let rx = "import {" + this.componentName + '} from "' + this.packageName + '";'; let rxTag = "<" + this.componentName + " />"; homeArray.unshift(rx); + // Get the first closing div, home shoud have one closing div. let splitPoint = homeArray.findIndex((value, index, array) => { if (value.match("")) { return index; } }); + // Insert the new class before the div // Splice the array into 2, before closing div and after let topHalf = homeArray.splice(0, splitPoint); diff --git a/packages/generator-electrode/component/index.js b/packages/generator-electrode/component/index.js index 87eb7d2cb6..d6febcecf4 100644 --- a/packages/generator-electrode/component/index.js +++ b/packages/generator-electrode/component/index.js @@ -20,7 +20,7 @@ module.exports = class extends Generator { } initializing() { - //check if the command is being run from within an existing app + // Check if the command is being run from within an existing app if (this.fs.exists(this.destinationPath("package.json"))) { var appPkg = this.fs.readJSON(this.destinationPath("package.json")); if ( @@ -122,6 +122,13 @@ module.exports = class extends Generator { name: "createDirectory", message: "Would you like to create a new directory for your project?", default: true + }, + { + type: "confirm", + name: "yarn", + message: "Would you like to yarn install packages?", + when: !this.props.yarn, + default: false } ]; @@ -295,21 +302,27 @@ module.exports = class extends Generator { } install() { - //git init and npmi for lerna lernaStructure + // Git init and npmi for lerna lernaStructure if (!this.isAddon) { - //reset the path to the actual root + // Reset the path to the actual root this.destinationRoot(this.oldRoot); this.destinationRoot(); this.spawnCommandSync("git", ["init"], { cwd: this.destinationPath() }); - this.spawnCommandSync("npm", ["install"], { - cwd: this.destinationPath() - }); + if (this.props.yarn) { + this.spawnCommandSync("yarn", ["install"], { + cwd: this.destinationPath() + }); + } else { + this.spawnCommandSync("npm", ["install"], { + cwd: this.destinationPath() + }); + } } - //install the dependencies for the package + // Install the dependencies for the package let packageDirectory = this.isAddon ? this.destinationPath() : this.destinationPath() + "/" + this.rootPath; diff --git a/packages/generator-electrode/generators/app/index.js b/packages/generator-electrode/generators/app/index.js index d3bc745476..d51a985420 100644 --- a/packages/generator-electrode/generators/app/index.js +++ b/packages/generator-electrode/generators/app/index.js @@ -222,16 +222,16 @@ module.exports = class extends Generator { } return githubUsername(this.props.authorEmail) - .then(username => username, () => '') - .then(username => { - return this.prompt({ - name: 'githubAccount', - message: 'GitHub username or organization', - default: username - }).then(prompt => { - this.props.githubAccount = prompt.githubAccount; + .then(username => username, () => '') + .then(username => { + return this.prompt({ + name: 'githubAccount', + message: 'GitHub username or organization', + default: username + }).then(prompt => { + this.props.githubAccount = prompt.githubAccount; + }); }); - }); } prompting() { @@ -344,7 +344,10 @@ module.exports = class extends Generator { //copy .eslintc into the client directory if (isSingleQuote) { - this.template("src/client/.eslintrc", this.destinationPath("src/client/.eslintrc")); + this.fs.copy( + this.templatePath("src/client/.eslintrc"), + this.destinationPath("src/client/.eslintrc") + ); } // Special handling for the server file diff --git a/packages/generator-electrode/test/spec/app.spec.js b/packages/generator-electrode/test/spec/app.spec.js index 5ea47b502c..ffdad54245 100644 --- a/packages/generator-electrode/test/spec/app.spec.js +++ b/packages/generator-electrode/test/spec/app.spec.js @@ -18,7 +18,7 @@ describe("electrode:app", function() { }); mockery.registerMock("github-username", function() { - return "unicornUser"; + return Promise.resolve(true); }); mockery.registerMock(require.resolve("generator-license/app"), helpers.createDummyGenerator());