When including marky-markdown it compiles but it doesn't include the required gen/grammar.json from highlights and then fails on runtime.
Highlights.prototype.loadGrammarsSync = function() {
var filePath, grammar, grammarPath, grammarsPath, k, len, ref, ref1;
if (this.registry.grammars.length > 1) {
return;
}
if (typeof this.includePath === 'string') {
if (fs.isFileSync(this.includePath)) {
this.registry.loadGrammarSync(this.includePath);
} else if (fs.isDirectorySync(this.includePath)) {
ref = fs.listSync(this.includePath, ['cson', 'json']);
for (k = 0, len = ref.length; k < len; k++) {
filePath = ref[k];
this.registry.loadGrammarSync(filePath);
}
}
}
grammarsPath = path.join(__dirname, '..', 'gen', 'grammars.json');
ref1 = JSON.parse(fs.readFileSync(grammarsPath));
for (grammarPath in ref1) {
grammar = ref1[grammarPath];
if (this.registry.grammarForScopeName(grammar.scopeName) != null) {
continue;
}
grammar = this.registry.createGrammar(grammarPath, grammar);
this.registry.addGrammar(grammar);
}
};
Highlights.prototype._loadGrammarsJSON = function(cb) {
var grammarsPath;
grammarsPath = path.join(__dirname, '..', 'gen', 'grammars.json');
return fs.readFile(grammarsPath, function(err, contents) {
var error;
try {
return cb(false, JSON.parse(contents));
} catch (error) {
err = error;
return cb(err);
}
});
};
Thanks for posting, I had a look and the problem here is that the path binding is being populated with the following wrapper:
(function () {
var ..., path, ...;
path = require('path');
});
Currently we only support detections of var path = require('path') in the top scope.
This is just a matter of extending the detection of the path require to this wrapper case, which should be straightforward it just has to be done carefully to properly take into account shadowing (eg what happens when path means something else in the outer wrapper).
Most helpful comment
Thanks for posting, I had a look and the problem here is that the
pathbinding is being populated with the following wrapper:Currently we only support detections of
var path = require('path')in the top scope.This is just a matter of extending the detection of the
pathrequire to this wrapper case, which should be straightforward it just has to be done carefully to properly take into account shadowing (eg what happens when path means something else in the outer wrapper).