Skip to content

Commit 42945b3

Browse files
committed
2 parents f0a836e + 8f6c8eb commit 42945b3

File tree

11 files changed

+1139
-1132
lines changed

11 files changed

+1139
-1132
lines changed

.npmignore

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
src/
2-
gulpfile.js
1+
# ignore everything
2+
*
3+
4+
# include these:
5+
!/lib/**/*
6+
!LICENSE.md
7+
!README.md
8+
9+
# exclude hidden files from the includes:
10+
.*

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ env:
77
language: node_js
88
node_js:
99
- 8
10-
- 9
10+
- 10
11+
- 12
1112
before_script:
1213
- yarn install --frozen-lockfile
1314
script:

package.json

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
77
"scripts": {
8-
"build": "tsc && chmod +x lib/cli.js",
8+
"clean": "rm -rf lib/",
9+
"build": "yarn clean && tsc && chmod +x lib/cli.js",
910
"test": "jest",
1011
"test:watch": "jest --watch",
1112
"test:ci": "jest --coverage",
@@ -40,13 +41,30 @@
4041
},
4142
"devDependencies": {
4243
"@types/glob": "^7.1.1",
44+
"@types/jest": "^24.0.15",
4345
"@types/mkdirp": "^0.5.1",
44-
"@types/node": "^12.0.3",
46+
"@types/node": "^12.0.8",
4547
"@types/yargs": "^8.0.2",
46-
"jest": "^23.6.0",
48+
"jest": "^24.8.0",
49+
"ts-jest": "^24.0.2",
4750
"typescript": "^3.5.1"
4851
},
4952
"jest": {
50-
"transform": {}
53+
"transform": {
54+
"^.+\\.ts$": "ts-jest"
55+
},
56+
"testRegex": "(test/.*|(src/.*\\.test))\\.ts$",
57+
"testPathIgnorePatterns": [
58+
"/node_modules/",
59+
"\\.d\\.ts$",
60+
"lib/",
61+
"example/",
62+
"coverage/"
63+
],
64+
"moduleFileExtensions": [
65+
"js",
66+
"ts",
67+
"json"
68+
]
5169
}
5270
}

src/cli.ts

Lines changed: 9 additions & 12 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';
8-
import {DtsCreator} from './DtsCreator';
9-
import {DtsContent} from "./DtsContent";
8+
import {DtsCreator} from './dts-creator';
9+
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

File renamed without changes.

src/DtsCreator.ts renamed to src/dts-creator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import * as process from 'process';
22
import * as path from'path';
33
import * as os from 'os';
44
import camelcase from "camelcase"
5-
import FileSystemLoader from './FileSystemLoader';
6-
import {DtsContent} from "./DtsContent";
5+
import FileSystemLoader from './file-system-loader';
6+
import {DtsContent} from "./dts-content";
77
import {Plugin} from "postcss";
88

99

File renamed without changes.

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import { DtsCreator } from './DtsCreator';
1+
import { DtsCreator } from './dts-creator';
22
export = DtsCreator;

test/dtsCreator.spec.js renamed to test/dts-creator.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
22

3-
var path = require('path');
4-
var assert = require('assert');
5-
var DtsCreator = require('../lib/DtsCreator').DtsCreator;
6-
var os = require('os');
3+
import * as path from 'path';
4+
5+
import * as assert from 'assert';
6+
import * as os from 'os';
7+
import { DtsCreator } from '../src/dts-creator';
78

89
describe('DtsCreator', () => {
910
var creator = new DtsCreator();

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"module": "commonjs",
44
"target": "es2015",
55
"declaration": true,
6-
"sourceMap": false,
6+
"sourceMap": true,
77
"strict": true,
88
"noImplicitAny": true,
99
"resolveJsonModule": true,
1010
"esModuleInterop": true,
11-
"outDir": "lib"
11+
"outDir": "lib",
12+
"allowSyntheticDefaultImports": true
1213
},
1314
"include": [
1415
"src/**/*.ts"

0 commit comments

Comments
 (0)