From 33a1f59e01118ef572a5f5155e0c45e84a78b4ed Mon Sep 17 00:00:00 2001 From: Lucas Azzola Date: Tue, 3 Oct 2017 19:34:08 +1100 Subject: [PATCH] Ensure package is published from dist/ with correct version number (#2963) --- package.json | 1 + scripts/build/build.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/package.json b/package.json index 4e8f8566..e16f6d81 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "webpack": "2.6.1" }, "scripts": { + "prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1", "test": "jest", "test-integration": "jest tests_integration", "lint": "cross-env EFF_NO_LINK_RULES=true eslint . --format node_modules/eslint-friendly-formatter", diff --git a/scripts/build/build.js b/scripts/build/build.js index a0a08afa..22a3fb2a 100755 --- a/scripts/build/build.js +++ b/scripts/build/build.js @@ -123,6 +123,10 @@ shell.cp("node_modules/sw-toolbox/sw-toolbox.js", `${docs}/sw-toolbox.js`); shell.echo("Copy package.json"); const pkgWithoutDependencies = Object.assign({}, pkg); delete pkgWithoutDependencies.dependencies; +pkgWithoutDependencies.scripts = { + prepublishOnly: + "node -e \"assert.equal(require('.').version, require('..').version)\"" +}; pipe(JSON.stringify(pkgWithoutDependencies, null, 2)).to("dist/package.json"); shell.echo("Copy README.md");