From 5fe74bef94317e28ddd2f36d442f360ea42aa87b Mon Sep 17 00:00:00 2001 From: Adeel Date: Sat, 18 Oct 2014 18:11:38 +0300 Subject: [PATCH] CLI: support for wildcards. Addresses gh-911. --- package.json | 3 +++ src/compiler/commandLineParser.ts | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0075230225415..d8c67b2f9ebfe 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,9 @@ "engines" : { "node" : ">=0.8.0" }, + "dependencies": { + "glob": "latest" + }, "devDependencies": { "jake" : "latest", "mocha" : "latest", diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 0e48953eaa7d5..a23b1e021c15a 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -24,7 +24,7 @@ module ts { type: "boolean", }, { - name: "emitBOM", + name: "emitBOM", type: "boolean" }, { @@ -197,11 +197,27 @@ module ts { } } else { - filenames.push(s); + testPathsAndPush(s); } } } + function testPathsAndPush(filenameOrPattern: string) { + var fs = require("fs"); + var path = require("path"); + + if (fs.existsSync(path.resolve(process.cwd(), filenameOrPattern))) { + filenames.push(filenameOrPattern); + return; + } + + var glob = require("glob"); + + glob.sync(filenameOrPattern).forEach(function(filename) { + filenames.push(filename); + }); + } + function parseResponseFile(filename: string) { var text = sys.readFile(filename);