Comparing version 2.0.1 to 2.1.0
# @gilamran/tsc-watch CHANGELOG | ||
## v2.1.0 - 27/11/2018 | ||
Exporting TscWatchClient for multiple instance of `tsc-watch` - (Thanks to @pronebird) | ||
## v2.0.0 - 12/2/2019 | ||
@@ -4,0 +8,0 @@ |
const { fork } = require('child_process'); | ||
const EventEmitter = require('events'); | ||
class TscEventsClient extends EventEmitter { | ||
class TscWatchClient extends EventEmitter { | ||
start(...args) { | ||
@@ -18,4 +18,2 @@ this.tsc = fork(require.resolve('./tsc-watch.js'), args, { stdio: 'inherit' }); | ||
const client = new TscEventsClient(); | ||
module.exports = client; | ||
module.exports = TscWatchClient; |
@@ -10,5 +10,3 @@ #!/usr/bin/env node | ||
let hadErrors = false; | ||
let firstTime = true; | ||
let firstSuccessKiller = null; | ||
@@ -18,5 +16,11 @@ let successKiller = null; | ||
let { onFirstSuccessCommand, onSuccessCommand, onFailureCommand, noColors, noClear, compiler, args } = extractArgs( | ||
process.argv, | ||
); | ||
const { | ||
onFirstSuccessCommand, | ||
onSuccessCommand, | ||
onFailureCommand, | ||
noColors, | ||
noClear, | ||
compiler, | ||
args, | ||
} = extractArgs(process.argv); | ||
@@ -50,3 +54,5 @@ function killProcesses(killAll) { | ||
print(noColors, noClear, lines); | ||
const { compilationError, compilationComplete } = detectState(lines); | ||
const state = detectState(lines); | ||
const compilationError = state.compilationError; | ||
const compilationComplete = state.compilationComplete; | ||
@@ -53,0 +59,0 @@ if (compilationComplete) { |
{ | ||
"name": "tsc-watch", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "The TypeScript compiler with onSuccess command", | ||
@@ -18,2 +18,5 @@ "scripts": { | ||
], | ||
"engines": { | ||
"node": ">=6.4.0" | ||
}, | ||
"author": "Gil Amran", | ||
@@ -30,3 +33,3 @@ "license": "MIT", | ||
"singleQuote": true, | ||
"printWidth": 120 | ||
"printWidth": 100 | ||
}, | ||
@@ -48,4 +51,5 @@ "dependencies": { | ||
"mocha-eventually": "^1.1.0", | ||
"sinon": "^4.1.3" | ||
"sinon": "^4.1.3", | ||
"typescript": "^3.3.3" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
[![Build Status](https://travis-ci.com/gilamran/tsc-watch.svg?branch=master)](https://travis-ci.com/gilamran/tsc-watch) | ||
# The TypeScript compiler with `--onSuccess` argument | ||
@@ -47,3 +49,4 @@ | ||
```javascript | ||
const watch = require('tsc-watch/client'); | ||
const TscWatchClient = require('tsc-watch/client'); | ||
const watch = new TscWatchClient(); | ||
@@ -62,3 +65,3 @@ watch.on('first_success', () => { | ||
watch.start(); | ||
watch.start('--project', '.'); | ||
@@ -65,0 +68,0 @@ try { |
@@ -5,3 +5,3 @@ const { expect } = require('chai'); | ||
const eventually = fn => mochaEventually(fn, 4000, 10); | ||
const tscWatchClient = require('../lib/client'); | ||
const TscWatchClient = require('../lib/client'); | ||
const { driver: tscWatchDriver } = require('./driver.js'); | ||
@@ -15,9 +15,12 @@ | ||
beforeEach(() => (this.callback = sinon.stub())); | ||
afterEach(() => tscWatchClient.kill()); | ||
beforeEach(() => { | ||
this.watchClient = new TscWatchClient(); | ||
this.callback = sinon.stub(); | ||
}); | ||
afterEach(() => this.watchClient.kill()); | ||
describe('Events', () => { | ||
it('Should emit "first_success" on first success', () => { | ||
tscWatchClient.on('first_success', this.callback); | ||
tscWatchClient.start('--noClear', '--out', './tmp/output.js', './tmp/fixtures/passing.ts'); | ||
this.watchClient.on('first_success', this.callback); | ||
this.watchClient.start('--noClear', '--out', './tmp/output.js', './tmp/fixtures/passing.ts'); | ||
@@ -28,4 +31,4 @@ return eventually(() => expect(this.callback.calledOnce).to.be.true); | ||
it('Should fire "subsequent_success" on subsequent successes', () => { | ||
tscWatchClient.on('subsequent_success', this.callback); | ||
tscWatchClient.start('--noClear', '--out', './tmp/output.js', './tmp/fixtures/passing.ts'); | ||
this.watchClient.on('subsequent_success', this.callback); | ||
this.watchClient.start('--noClear', '--out', './tmp/output.js', './tmp/fixtures/passing.ts'); | ||
tscWatchDriver.modifyAndSucceedAfter(1500); | ||
@@ -37,4 +40,4 @@ | ||
it('Should fire "compile_errors" on when tsc compile errors occur', () => { | ||
tscWatchClient.on('compile_errors', this.callback); | ||
tscWatchClient.start('--noClear', '--out', './tmp/output.js', './tmp/fixtures/failing.ts'); | ||
this.watchClient.on('compile_errors', this.callback); | ||
this.watchClient.start('--noClear', '--out', './tmp/output.js', './tmp/fixtures/failing.ts'); | ||
@@ -41,0 +44,0 @@ return eventually(() => expect(this.callback.calledOnce).to.be.true); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23928
23
461
80
6