From 5ba0ad4703c3fbcdab18423aa9b809a0d4bfadc9 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Wed, 15 Aug 2018 10:43:15 +0200 Subject: [PATCH 1/3] Add support for globing arguments on Windows This makes calls like "tsfmt src/*.ts" work on Windows. --- lib/cli.ts | 3 ++- package.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/cli.ts b/lib/cli.ts index 6a95779..5386c69 100644 --- a/lib/cli.ts +++ b/lib/cli.ts @@ -9,7 +9,7 @@ import * as ts from "typescript"; import * as fs from "fs"; import * as path from "path"; import * as commandpost from "commandpost"; - +import * as globArgs from "glob-args"; import * as lib from "./"; import { getConfigFileName, readFilesFromTsconfig } from "./utils"; @@ -94,6 +94,7 @@ let root = commandpost process.stdout.write(root.helpText() + "\n"); return; } + files = globArgs(files); if (verbose) { const printPool: { [name: string]: string; } = {}; diff --git a/package.json b/package.json index 08d1681..4be97c5 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ }, "dependencies": { "commandpost": "^1.0.0", - "editorconfig": "^0.15.0" + "editorconfig": "^0.15.0", + "glob-args": "^0.2.1" }, "peerDependencies": { "typescript": "^2.1.6 || ^3.0.0 || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev" From 15a62be87b7fef4ff0f43f2df1bbe44e3002dede Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Thu, 16 Aug 2018 09:57:09 +0200 Subject: [PATCH 2/3] fixup: use glob directly --- lib/cli.ts | 11 +++++++++-- package.json | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/cli.ts b/lib/cli.ts index 5386c69..b1eda81 100644 --- a/lib/cli.ts +++ b/lib/cli.ts @@ -9,7 +9,7 @@ import * as ts from "typescript"; import * as fs from "fs"; import * as path from "path"; import * as commandpost from "commandpost"; -import * as globArgs from "glob-args"; +import * as glob from "glob"; import * as lib from "./"; import { getConfigFileName, readFilesFromTsconfig } from "./utils"; @@ -94,7 +94,14 @@ let root = commandpost process.stdout.write(root.helpText() + "\n"); return; } - files = globArgs(files); + let matchedFiles = new Array(); + files.forEach((pattern) => { + const matched = glob.sync(pattern); + if (matched) { + matchedFiles.concat(matched); + } + }); + files = matchedFiles; if (verbose) { const printPool: { [name: string]: string; } = {}; diff --git a/package.json b/package.json index 4be97c5..54e838d 100644 --- a/package.json +++ b/package.json @@ -34,12 +34,13 @@ "dependencies": { "commandpost": "^1.0.0", "editorconfig": "^0.15.0", - "glob-args": "^0.2.1" + "glob": "^7.1.2" }, "peerDependencies": { "typescript": "^2.1.6 || ^3.0.0 || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev" }, "devDependencies": { + "@types/glob": "^5.0.35", "@types/mkdirp": "^0.5.0", "@types/mocha": "^5.0.0", "@types/node": "^10.3.0", From 9357cc928a72f80feb8cb45f65404278052f4bc6 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Wed, 22 Aug 2018 13:05:33 +0200 Subject: [PATCH 3/3] fixup: make test pass --- lib/cli.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cli.ts b/lib/cli.ts index b1eda81..2cd2569 100644 --- a/lib/cli.ts +++ b/lib/cli.ts @@ -97,8 +97,8 @@ let root = commandpost let matchedFiles = new Array(); files.forEach((pattern) => { const matched = glob.sync(pattern); - if (matched) { - matchedFiles.concat(matched); + if (matched && matched.length > 0) { + matchedFiles = matchedFiles.concat(matched); } }); files = matchedFiles;