Skip to content

Commit

Permalink
fix(init): add standard-version entry to package.json (#32)
Browse files Browse the repository at this point in the history
- move `prepend-file-cli` from `devDeps` to `deps`
  • Loading branch information
ybiquitous committed Oct 10, 2017
1 parent e0db7c7 commit 17a9dc2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"lint-staged": "^4.2.3",
"markdownlint-cli": "^0.3.1",
"npm-run-all": "^4.1.1",
"prepend-file-cli": "^1.0.6",
"semver": "^5.4.1",
"standard-version": "^4.2.0",
"yargs": "^9.0.1"
Expand All @@ -51,8 +52,7 @@
"babel-register": "^6.26.0",
"codecov": "^2.3.0",
"mocha": "^4.0.1",
"nyc": "^11.2.1",
"prepend-file-cli": "^1.0.6"
"nyc": "^11.2.1"
},
"scripts": {
"build": "babel src/ -d lib/",
Expand Down
10 changes: 9 additions & 1 deletion src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Init {
async updatePackageFile() {
const packageInfo = JSON.parse(await this.readFile('package.json'))

// update 'scripts'
const { scripts } = packageInfo
Object.assign(scripts, {
'test:watch': `${scripts.test} --watch`,
Expand All @@ -39,7 +40,14 @@ class Init {
scripts[key] = originalPackage.scripts[key]
})

Object.assign(packageInfo['lint-staged'], originalPackage['lint-staged'])
// update other keys
const keys = ['lint-staged', 'standard-version']
keys.forEach((key) => {
if (!(key in packageInfo)) {
packageInfo[key] = {}
}
Object.assign(packageInfo[key], originalPackage[key])
})

await this.writeFile('package.json', JSON.stringify(packageInfo, null, 2))
}
Expand Down
6 changes: 6 additions & 0 deletions test/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ suite('init', () => {
'*.md': 'markdownlint',
'*.css': 'xyz',
})

assert.deepStrictEqual(pkg['standard-version'], {
scripts: {
postchangelog: 'prepend CHANGELOG.md "<!-- markdownlint-disable -->\n"',
},
})
})

test('copy .editorconfig', async () => {
Expand Down

0 comments on commit 17a9dc2

Please sign in to comment.