1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

next init: Exit non-zero when refusing to run in 'pages' dir. (#156)

Should only exit `0` if the command was successful. The command refusing to execute should be considered a failure.

Also, this condition can be detected synchronously, no need to wait on the async existence check.
This commit is contained in:
Tim Oxley 2016-10-29 23:03:05 -07:00 committed by Naoyuki Kanezawa
parent 4c2f381e74
commit 5595232f58

View file

@ -12,13 +12,13 @@ const argv = parseArgs(process.argv.slice(2), {
const dir = resolve(argv._[0] || '.') const dir = resolve(argv._[0] || '.')
exists(join(dir, 'package.json'))
.then(async present => {
if (basename(dir) === 'pages') { if (basename(dir) === 'pages') {
console.warn('Your root directory is named "pages". This looks suspicious. You probably want to go one directory up.') console.warn('Your root directory is named "pages". This looks suspicious. You probably want to go one directory up.')
return process.exit(1)
} }
exists(join(dir, 'package.json'))
.then(async present => {
if (!present) { if (!present) {
await writeFile(join(dir, 'package.json'), basePackage.replace(/my-app/g, basename(dir))) await writeFile(join(dir, 'package.json'), basePackage.replace(/my-app/g, basename(dir)))
} }