diff --git a/boilerplate/.gitignore b/boilerplate/.gitignore index f06235c46..d4d7e3f61 100644 --- a/boilerplate/.gitignore +++ b/boilerplate/.gitignore @@ -1,2 +1,3 @@ node_modules dist +*.log diff --git a/npm/postinstall.js b/npm/postinstall.js index e047c35b8..f108e1bbc 100644 --- a/npm/postinstall.js +++ b/npm/postinstall.js @@ -2,12 +2,31 @@ const stat = require("fs").stat const spawn = require("child_process").spawn const join = require("path").join const pkg = require("../package.json") - +const fs = require("fs-extra") // no need for th is step on CI if (process.env.CI) { process.exit(0) } +const boilerplateDir = join(__dirname, "../boilerplate") + +stat(join(boilerplateDir, ".npmignore"), function(err) { + if (err) { + console.log("No .npmignore in boilerplate to rename") + return true + } + + fs.move( + join(boilerplateDir, ".npmignore"), + join(boilerplateDir, ".gitignore"), + function(err) { + if (err) { + throw new Error("Cannot rename .npmignore to .gitignore in boilerplate") + } + } + ) +}) + stat("lib", function(error, stats1) { if (!error && stats1.isDirectory()) { return true diff --git a/src/bin/commands/setup.js b/src/bin/commands/setup.js index 96463193e..8f95e8db1 100644 --- a/src/bin/commands/setup.js +++ b/src/bin/commands/setup.js @@ -2,7 +2,7 @@ import "babel-polyfill" import color from "chalk" import { join } from "path" -import fs from "fs-extra" +import fs from "fs-promise" import { prompt } from "../utils/inquirer" import questions, { defaultTestAnswers } from "../data/questions" @@ -15,17 +15,10 @@ import { export default async function setup(argv) { const cwd = process.cwd() + const testMode = argv.test try { - let answers - const testMode = argv.test - - if (testMode) { - answers = defaultTestAnswers - } - else { - answers = await prompt(questions) - } + const answers = testMode ? defaultTestAnswers : await prompt(questions) const { name, homepage, ...statinamic } = answers const devDependencies = { @@ -44,11 +37,11 @@ export default async function setup(argv) { devDependencies, } - fs.writeJsonSync(join(cwd, "package.json"), pkg) + await fs.writeJson(join(cwd, "package.json"), pkg) console.log(color.green("Generated package.json file")) const boilerplatePath = join(__dirname, "../../../boilerplate") - fs.copySync(boilerplatePath, cwd) + await fs.copy(boilerplatePath, cwd) console.log(color.green("Copied boilerplate")) console.log(