Undoing merge of PR #278

This commit is contained in:
walterhiggins 2016-01-01 12:55:53 +00:00
parent eef507fdfe
commit badf8b5470

View file

@ -165,14 +165,20 @@ When resolving module names to file paths, ScriptCraft uses the following rules.
if ( file.exists() ) { if ( file.exists() ) {
return fileExists(file); return fileExists(file);
} else { } else {
if ((file = new File(parentDir, moduleName)).exists()) { // try appending a .js to the end
return fileExists(file); pathWithJSExt = file.canonicalPath + '.js';
} else if ((file = new File(parentDir, moduleName + ".js")).exists()) { // try .js extension file = new File( parentDir, pathWithJSExt );
if (file.exists()) {
return file; return file;
} else if ((file = new File(parentDir, moduleName + ".json")).exists()) { // try .json extension } else {
file = new File(pathWithJSExt);
if ( file.exists() ) {
return file; return file;
} }
} }
}
}
return null; return null;
} }
/* /*
@ -244,9 +250,6 @@ When resolving module names to file paths, ScriptCraft uses the following rules.
} }
buffered.close(); // close the stream so there's no file locks buffered.close(); // close the stream so there's no file locks
if(canonizedFilename.substring(canonizedFilename.length - 5) === ".json") // patch code when it is json
code = "module.exports = (" + code + ");";
moduleInfo = { moduleInfo = {
loaded: false, loaded: false,
id: canonizedFilename, id: canonizedFilename,