Skip to content

Commit

Permalink
Add a prepublish step to package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Sep 12, 2014
1 parent 4d4daa0 commit 0322beb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###

Expand Down
7 changes: 2 additions & 5 deletions bin/without_eval
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down

0 comments on commit 0322beb

Please sign in to comment.