Merge pull request #127 from jasonk/master
Fix require() to work with index.js
This commit is contained in:
commit
a18e9651e8
1 changed files with 7 additions and 3 deletions
|
@ -80,7 +80,7 @@ module specification, the '.js' suffix is optional.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// look for an index.js file
|
// look for an index.js file
|
||||||
var indexJsFile = new File( dir + './index.js' );
|
var indexJsFile = new File( dir, './index.js' );
|
||||||
if ( indexJsFile.exists() ) {
|
if ( indexJsFile.exists() ) {
|
||||||
return indexJsFile;
|
return indexJsFile;
|
||||||
} else {
|
} else {
|
||||||
|
@ -244,7 +244,9 @@ When resolving module names to file paths, ScriptCraft uses the following rules.
|
||||||
try {
|
try {
|
||||||
compiledWrapper = eval(code);
|
compiledWrapper = eval(code);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw 'Error:' + e + ' while evaluating module ' + canonizedFilename;
|
throw new Error( "Error evaluating module " + path
|
||||||
|
+ " at " + canonizedFilename + " line #" + e.lineNumber
|
||||||
|
+ ". Error was: " + e.message, canonizedFilename, e.lineNumber );
|
||||||
}
|
}
|
||||||
var __dirname = '' + file.parentFile.canonicalPath;
|
var __dirname = '' + file.parentFile.canonicalPath;
|
||||||
var parameters = [
|
var parameters = [
|
||||||
|
@ -259,7 +261,9 @@ When resolving module names to file paths, ScriptCraft uses the following rules.
|
||||||
.apply(moduleInfo.exports, /* this */
|
.apply(moduleInfo.exports, /* this */
|
||||||
parameters);
|
parameters);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw 'Error:' + e + ' while executing module ' + canonizedFilename;
|
throw new Error( "Error executing module " + path
|
||||||
|
+ " at " + canonizedFilename + " line #" + e.lineNumber
|
||||||
|
+ ". Error was: " + e.message, canonizedFilename, e.lineNumber )
|
||||||
}
|
}
|
||||||
if ( hooks ) {
|
if ( hooks ) {
|
||||||
hooks.loaded( canonizedFilename );
|
hooks.loaded( canonizedFilename );
|
||||||
|
|
Reference in a new issue