Skip to content

Commit

Permalink
Let output be a filepath or a directory name.
Browse files Browse the repository at this point in the history
  • Loading branch information
doug authored May 8, 2018
1 parent d7beb04 commit 76739ef
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tswidgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import {writeFileSync} from 'fs';
import {resolve} from 'path';
import {dirname, resolve} from 'path';
import * as yargs from 'yargs';

import {extract} from './extractor';
Expand All @@ -34,9 +34,12 @@ if (paths.length < 1) {
}
const info = extract(paths);
const output = pack(info);
let outDir = argv.output || __dirname;
if (outDir.includes('.')) {
outDir = dirname(outDir);
}

for (const file of output) {
const outDir = argv.output || __dirname;
const outPath = resolve(outDir, file.name);
writeFileSync(outPath, file.content);
console.log(`Written ${outPath}`);
Expand Down

0 comments on commit 76739ef

Please sign in to comment.