From eaa4c94e5380d4074ed22045e239fb93d048be05 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Thu, 13 Sep 2018 22:09:45 +0800 Subject: [PATCH] feat: script for sync manifest version --- .eslintrc.json | 3 ++- package.json | 1 + scripts/version.js | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 scripts/version.js diff --git a/.eslintrc.json b/.eslintrc.json index 9affda5..37d4b01 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,7 +3,8 @@ "env": { "browser": true, "commonjs": true, - "es6": true + "es6": true, + "node": true }, "parserOptions": { "ecmaFeatures": { diff --git a/package.json b/package.json index 4345d70..fdfb088 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "scripts": { "start": "webpack --watch", "dev": "webpack", + "stamp": "node scripts/version.js", "prod": "NODE_ENV=production webpack && cd dist && rm -f ./gitako.zip && zip gitako.zip -r *" }, "dependencies": { diff --git a/scripts/version.js b/scripts/version.js new file mode 100644 index 0000000..d9d847c --- /dev/null +++ b/scripts/version.js @@ -0,0 +1,10 @@ +const fs = require('fs') +const path = require('path') + +const rootPath = path.resolve(__dirname, '../') +const packageJSON = require(path.resolve(rootPath, 'package.json')) +const manifestPath = path.resolve(rootPath, 'src/manifest.json'); +const manifest = require(manifestPath) + +manifest.version = packageJSON.version +fs.writeFileSync(manifestPath, JSON.stringify(manifest), 'utf-8')