Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
+6
-0
| Changes | ||
| ======= | ||
| 1.2.0 | ||
| ----- | ||
| * [Issue #10][issue 10] | ||
| 1.1.0 | ||
@@ -33,2 +38,3 @@ ----- | ||
| [grunt]: http://gruntjs.com/ | ||
| [issue 10]: https://github.com/dvberkel/grunt-peg/issues/10 | ||
| [pull 9]: https://github.com/dvberkel/grunt-peg/pull/9 | ||
@@ -35,0 +41,0 @@ [issue 8]: https://github.com/dvberkel/grunt-peg/issues/8 |
+5
-0
@@ -46,2 +46,7 @@ /* | ||
| options: { cache: true } | ||
| }, | ||
| plugin_options: { | ||
| src: 'test/fixtures/coffee-plugin.peg', | ||
| dest: 'tmp/plugin_options_standard', | ||
| options: { plugins: [ 'pegjs-coffee-plugin' ] } | ||
| } | ||
@@ -48,0 +53,0 @@ }, |
+3
-2
| { | ||
| "name": "grunt-peg", | ||
| "description": "A grunt multi task that generates parsers from PEG grammars.", | ||
| "version": "1.1.0", | ||
| "version": "1.2.0", | ||
| "homepage": "https://github.com/dvberkel/grunt-peg", | ||
@@ -36,3 +36,4 @@ "author": { | ||
| "grunt": "~0.4.1", | ||
| "grunt-bumpup": "~0.2.0" | ||
| "grunt-bumpup": "~0.2.0", | ||
| "pegjs-coffee-plugin": "~0.2.1" | ||
| }, | ||
@@ -39,0 +40,0 @@ "peerDependencies": { |
+29
-0
@@ -107,2 +107,29 @@ # grunt-peg | ||
| ##### Note on plugins | ||
| If you want to pass plugins to PEG.js make sure that the plugin is | ||
| installed and referenced by the module name. For example, for the | ||
| [pegjs-coffee-plugin][] one should first install the plugin | ||
| ```js | ||
| npm install --save-dev pegjs-coffee-plugin | ||
| ``` | ||
| and then configure the tasks with the module name. | ||
| ```js | ||
| grunt.initConfig({ | ||
| peg: { | ||
| options: { trackLineAndColumn: true }, | ||
| example : { | ||
| src: "grammar/example.peg", | ||
| dest: "grammar/example.js", | ||
| options: { | ||
| plugins: [ "pegjs-coffee-plugin" ] | ||
| } | ||
| } | ||
| } | ||
| }) | ||
| ``` | ||
| ## PEG.js dependency | ||
@@ -123,2 +150,3 @@ | ||
| * 2014-01-05 v1.2.0 Support plugins | ||
| * 2014-01-05 v1.1.0 Support PEG 0.8.0 | ||
@@ -143,1 +171,2 @@ * 2013-08-21 v1.0.0 Remove support for old-style options | ||
| [#6]: https://github.com/dvberkel/grunt-peg/pull/6 | ||
| [pegjs-coffee-plugin]: https://github.com/Dignifiedquire/pegjs-coffee-plugin |
+19
-2
@@ -11,3 +11,4 @@ /* | ||
| var PEG = require('pegjs'); | ||
| var PEG = require('pegjs'); | ||
| var path = require('path'); | ||
@@ -22,3 +23,4 @@ module.exports = function(grunt) { | ||
| exportVar: 'module.exports', | ||
| output: 'source' | ||
| output: 'source', | ||
| plugins: [] | ||
| }); | ||
@@ -45,2 +47,17 @@ | ||
| // Require all plugins just like the pegjs CLI | ||
| options.plugins = options.plugins.map(function(plugin){ | ||
| var id = /^(\.\/|\.\.\/)/.test(plugin) ? path.resolve(plugin) : plugin; | ||
| var mod; | ||
| try { | ||
| mod = require(id); | ||
| } catch (e) { | ||
| if (e.code !== "MODULE_NOT_FOUND") { grunt.fail.fatal(e); } | ||
| grunt.fail.fatal('Can\'t load module \'' + id + '\'.'); | ||
| } | ||
| return mod; | ||
| }); | ||
| // Generate the parser. | ||
@@ -47,0 +64,0 @@ var time = Date.now(); |
+9
-0
@@ -52,3 +52,12 @@ 'use strict'; | ||
| test.done(); | ||
| }, | ||
| plugin_options: function(test) { | ||
| test.expect(1); | ||
| var actual = grunt.file.read('tmp/plugin_options_standard'); | ||
| var expected = grunt.file.read('test/expected/plugin_options'); | ||
| test.equal(actual, expected, 'Unexpected parser generated for plugin_options_standard'); | ||
| test.done(); | ||
| } | ||
| }; |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
39692
27.64%15
15.38%177
17.22%169
19.86%6
20%1
Infinity%