Reputation: 1620
In my grammar rule i need to check whether directory exists.
However, seems i'm unable to use Node.JS
-specific code in grammar JS.
Is it correct? Any workaround?
Thanks and sorry if a question was a silly one :)
Example grammar:
{
var fs = require('fs');
function isDirectoryExists(dir) {
return fs.existsSync(path);
}
}
Main = "stub"
Output from the PEG.js online playground:
require is not defined
Upvotes: 1
Views: 174
Reputation: 1620
Node.JS
-specific code perfectly works in Node environment on the host.
But not in my browser, there is no Node there.
So, PEG.JS
online playground can execute only vanilla JavaScript code.
But this is a limitation of browser, not a PEG.js.
Upvotes: 1