Skip to content

Commit 9ac59f9

Browse files
committed
Merge branch 'promisify-glob'
2 parents 46f11ef + 886ba72 commit 9ac59f9

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/cli.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
import * as path from 'path';
44
import * as chokidar from 'chokidar';
5-
import glob from 'glob';
5+
import _glob from 'glob';
66
import * as yargs from 'yargs';
77
import chalk from 'chalk';
88
import {DtsCreator} from './dts-creator';
99
import {DtsContent} from "./dts-content";
10+
import * as util from "util";
11+
12+
const glob = util.promisify(_glob);
1013

1114
const yarg = yargs.usage('Create .css.d.ts from CSS modules *.css files.\nUsage: $0 [options] <input directory>')
1215
.example('$0 src/styles', '')
@@ -39,7 +42,7 @@ async function writeFile(f: string): Promise<void> {
3942
}
4043
};
4144

42-
function main() {
45+
async function main() {
4346
let rootDir: string;
4447
let searchDir: string;
4548
if(argv.h) {
@@ -66,14 +69,8 @@ function main() {
6669
});
6770

6871
if(!argv.w) {
69-
glob(filesPattern, {}, (err, files) => {
70-
if(err) {
71-
console.error(err);
72-
return;
73-
}
74-
if(!files || !files.length) return;
75-
files.forEach(writeFile);
76-
});
72+
const files = await glob(filesPattern);
73+
files.forEach(writeFile);
7774
} else {
7875
console.log('Watch ' + filesPattern + '...');
7976

0 commit comments

Comments
 (0)