Skip to content

Commit

Permalink
Make 'npm test' run on Windows (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzoz authored and roman-vanesyan committed Jun 28, 2018
1 parent 3b8e519 commit 3f4f5ca
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Makefile
@@ -1,7 +1,6 @@

TESTS = $(shell find test/test.*.js)

test:
@./test/run $(TESTS)
@./test/run.js

.PHONY: test
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -16,7 +16,7 @@
},
"scripts": {
"lint": "eslint index.js",
"test": "make test && npm run test-typings",
"test": "node test/run.js && npm run test-typings",
"test-typings": "node_modules/typescript/bin/tsc -p tsconfig.json"
},
"main": "index",
Expand Down
22 changes: 22 additions & 0 deletions test/run.js
@@ -0,0 +1,22 @@
#!/usr/bin/env node

const { spawnSync } = require('child_process')
const { readdirSync } = require('fs')
const { extname, join } = require('path')

process.env.NODE_ENV = 'test';

process.stdout.write('\n')
readdirSync(__dirname).forEach((file) => {
if (!file.startsWith('test.') || extname(file) !== '.js')
return;
process.stdout.write(`\x1b[90m ${file}\x1b[0m `);
const result = spawnSync(process.argv0, [ join('test', file) ]);
if (result.status === 0) {
process.stdout.write('\x1b[36m✓\x1b[0m\n');
} else {
process.stdout.write('\x1b[31m✖\x1b[0m\n');
console.error(result.stderr.toString('utf8'));
process.exit(result.status);
}
})

0 comments on commit 3f4f5ca

Please sign in to comment.