From 9511e2618de5cf8917e4aee13d623a75b69a503d Mon Sep 17 00:00:00 2001 From: Norton Wang Date: Sun, 18 Mar 2018 09:11:27 -0400 Subject: [PATCH] Fix an issue with the --lib argument in asc and allow specifying files (#42) --- NOTICE | 1 + bin/asc.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NOTICE b/NOTICE index c4529505..be312e1b 100644 --- a/NOTICE +++ b/NOTICE @@ -6,6 +6,7 @@ under the licensing terms detailed in LICENSE. * Daniel Wirtz * Max Graey * Igor Sbitnev +* Norton Wang ================================================================================ diff --git a/bin/asc.js b/bin/asc.js index 4d9441b5..96526381 100644 --- a/bin/asc.js +++ b/bin/asc.js @@ -157,7 +157,7 @@ exports.main = function main(argv, options, callback) { if (typeof args.lib === "string") { args.lib = args.lib.split(","); } - Array.prototype.push.apply(libDirs, args.lib.map(trim)); + Array.prototype.push.apply(libDirs, args.lib.map(lib => lib.trim())); } // Begin parsing @@ -267,7 +267,13 @@ exports.main = function main(argv, options, callback) { for (let i = 0, k = libDirs.length; i < k; ++i) { if (i === 0 && hasBundledLibrary) continue; let libDir = libDirs[i]; - let libFiles = listFiles(libDir); + let libFiles; + if (libDir.endsWith(".ts")) { + libFiles = [path.basename(libDir)]; + libDir = path.dirname(libDir); + } else { + libFiles = listFiles(libDir); + } for (let j = 0, l = libFiles.length; j < l; ++j) { let libPath = libFiles[j]; let libText = readFile(path.join(libDir, libPath));