Skip to content

Commit 105e91c

Browse files
committed
fix(cli): run npm init -y if needed
1 parent bd0d64e commit 105e91c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The below assumes a new directory and project is required. This is likely what y
3030
```bash
3131
mkdir new-project
3232
cd new-project
33-
npm init -y && npx @pattern-lab/cli -c patternlab init
33+
npx @pattern-lab/cli -c patternlab init
3434
```
3535
> If you get an error stating that `npx` is not installed, ensure you are on `npm 5.2.0` or later by running `npm -v` or install it globally with `npm install -g npx`. [Learn more about npx.](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b)
3636
1. Follow the on-screen prompts to choose your Edition and a Starterkit should you want one.

packages/cli/bin/scaffold.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22
const path = require('path');
3+
const execa = require('execa');
4+
const fs = require('fs');
35
const wrapAsync = require('./utils').wrapAsync;
46
const mkdirsAsync = require('./utils').mkdirsAsync;
57

@@ -14,6 +16,9 @@ const mkdirsAsync = require('./utils').mkdirsAsync;
1416
*/
1517
const scaffold = (projectDir, sourceDir, publicDir, exportDir) =>
1618
wrapAsync(function*() {
19+
if (!fs.existsSync(path.resolve(projectDir, 'package.json'))) {
20+
execa.sync('npm', ['init', '-y']);
21+
}
1722
/**
1823
* Create mandatory files structure
1924
* 1. Create project source directory

0 commit comments

Comments
 (0)