From 0322beb0aa5d170e427d76f668afaf3088fc5e29 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 12 Sep 2014 16:54:28 +0200 Subject: [PATCH] Add a prepublish step to package.json --- README.md | 3 ++- bin/without_eval | 7 ++----- package.json | 5 ++++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 82ecd6b77c..531f38063a 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,8 @@ in a context with such a The `bin/without_eval` script can be used to generate a version of `acorn.js` that has the generated code inlined, and can thus run -without evaluating anything. +without evaluating anything. In versions of this library downloaded +from NPM, this script will be available as `acorn_csp.js`. ### acorn_loose.js ### diff --git a/bin/without_eval b/bin/without_eval index fd8befb6b0..e9ef18f380 100755 --- a/bin/without_eval +++ b/bin/without_eval @@ -6,15 +6,12 @@ var acornSrc = fs.readFileSync(require.resolve("../acorn"), "utf8"); var acorn = require("../acorn"), walk = require("../util/walk"); var ast = acorn.parse(acornSrc); -var touchups = []; -var uses = [], declaration; +var touchups = [], uses = []; walk.simple(ast, { FunctionDeclaration: function(node) { - if (node.id.name == "makePredicate") { + if (node.id.name == "makePredicate") touchups.push({text: "// Removed to create an eval-free library", from: node.start, to: node.end}); - declaration = node; - } }, VariableDeclaration: function(node) { node.declarations.forEach(function(decl) { diff --git a/package.json b/package.json index 8f029de5cb..808e0a8ca7 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,10 @@ "url": "http://marijnhaverbeke.nl/git/acorn"}, "licenses": [{"type": "MIT", "url": "http://marijnhaverbeke.nl/acorn/LICENSE"}], - "scripts": {"test": "node test/run.js"}, + "scripts": { + "test": "node test/run.js", + "prepublish": "bin/without_eval > acorn_csp.js" + }, "bin": {"acorn": "./bin/acorn"}, "devDependencies": {"regenerate": "~0.6.2", "unicode-7.0.0": "~0.1.5"}