Skip to content

Commit

Permalink
yarn install for component
Browse files Browse the repository at this point in the history
  • Loading branch information
ameyakoshti authored and a0k00e3 committed Jul 17, 2017
1 parent d4dc390 commit 12428e3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
2 changes: 2 additions & 0 deletions packages/generator-electrode/component-add/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("</div>")) {
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);
Expand Down
27 changes: 20 additions & 7 deletions packages/generator-electrode/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
}
];

Expand Down Expand Up @@ -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;
Expand Down
23 changes: 13 additions & 10 deletions packages/generator-electrode/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/generator-electrode/test/spec/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 12428e3

Please sign in to comment.