Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit e087641

Browse files
Automatically bump manifest.json version when using npm version to avoid mistakes
1 parent a247195 commit e087641

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

bin/_npm_version.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
/* eslint-env node */
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
const {version, description} = require('../package.json');
8+
9+
const manifestPath = path.join(__dirname, '..', 'manifest.json');
10+
const original = fs.readFileSync(manifestPath, 'utf8');
11+
const manifestBody = JSON.parse(original);
12+
manifestBody.version = version;
13+
manifestBody.description = description;
14+
const updated = JSON.stringify(manifestBody, null, 4);
15+
fs.writeFileSync(manifestPath, updated);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"test:unit:coveralls": "npm run test:unit:coverage && nyc report --reporter=text-lcov | coveralls",
1515
"test": "npm run lint && npm run test:unit:coverage && npm run test:unit:coverage:report",
1616
"test:server": "sh -c 'node test/testing-server.js \"$@\" | bunyan' --",
17-
"start": "npm run build && \"$FIREFOX_BIN\" --no-remote --profile PRIV/profile --jsconsole"
17+
"start": "npm run build && \"$FIREFOX_BIN\" --no-remote --profile PRIV/profile --jsconsole",
18+
"version": "bin/_npm_version.js && git add manifest.json"
1819
},
1920
"author": "Joris van der Wel <joris@jorisvanderwel.com>",
2021
"license": "Apache-2.0",

0 commit comments

Comments
 (0)