diff --git a/README.md b/README.md index 1a0345a..c002af9 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ $ ### .load [delay] -Load a local or remote Javascript file line by line in to the REPL. A `delay` between each line of code's execution can be specified in milliseconds. +Load a local or remote Javascript file line by line in to the REPL. A `delay` between each line of code's execution can be specified in milliseconds. If `` is a directory, triple will attempt to load `app.js` then `index.js` from the directory. ```bash $ triple diff --git a/lib/triple.js b/lib/triple.js index f229701..35d4784 100644 --- a/lib/triple.js +++ b/lib/triple.js @@ -347,7 +347,19 @@ function load(tokens, rl) { // probably a file } else { if (fs.existsSync(location)) { - return sendLoadCommand(rl, location, fs.readFileSync(location).toString(), delay); + + // if it's a folder + if (fs.lstatSync(location).isDirectory()) { + + // try app.js and/or index.js + var tries = ['app.js', 'index.js']; + for (var i = 0; i < tries.length; i++) { + var file = path.join(location, tries[i]); + if (fs.existsSync(file)) { + return sendLoadCommand(rl, file, fs.readFileSync(file, 'utf8'), delay); + } + } + } } }