Skip to content

Commit

Permalink
fix for running install commands on windows and better error reportin…
Browse files Browse the repository at this point in the history
…g when the commands fail
  • Loading branch information
okwolf committed Nov 20, 2018
1 parent 0622045 commit 7d03d11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,20 @@ const packageJson = require(packageJsonPath);
packageJson.name = name;
fs.writeJsonSync(packageJsonPath, packageJson, { spaces: 2 });

const runNpmCommand = command =>
spawnSync("npm", command.split(" "), {
const installPackageWithFlags = (package, ...args) => {
const installResults = spawnSync("npm", ["install", package, ...args], {
cwd: projectPath,
stdio: "inherit"
stdio: "inherit",
shell: true
});
runNpmCommand("install --save hyperapp");
runNpmCommand("install --save-dev hyperapp-scripts");
if (installResults.error) {
exitWithError(
`Error while installing ${cyan(package)}: ${installResults.error}`
);
}
};
installPackageWithFlags("hyperapp", "--save");
installPackageWithFlags("hyperapp-scripts", "--save-dev");

console.log();
console.log(`Success! Created ${name} in ${process.cwd()}`);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-hyperapp",
"version": "0.1.0",
"version": "0.1.1",
"description": "Create Hyperapps with no build configuration",
"bin": {
"create-hyperapp": "./bin/index.js"
Expand Down

0 comments on commit 7d03d11

Please sign in to comment.