Skip to content

Commit 7a21a2b

Browse files
committed
remove ts-node from deps
1 parent 9c6777f commit 7a21a2b

File tree

8 files changed

+28
-18
lines changed

8 files changed

+28
-18
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ It restarts target node process when any of required files changes (as standard
66

77
## Install
88

9+
`ts-node` is not a package dependency of `ts-node-dev` just to give user freedom of using needed `ts-node` version.
10+
911
```
10-
yarn add ts-node-dev
12+
yarn add ts-node-dev ts-node
1113
```
1214

1315
```
14-
npm i ts-node-dev --global
16+
npm i ts-node-dev ts-node --global
1517
```
1618

1719
## Usage
@@ -22,14 +24,16 @@ ts-node-dev [node-dev|ts-node flags] [ts-node-dev flags] [script] [script argume
2224

2325
So you just combine [node-dev](https://github.com/fgnass/node-dev) and [ts-node](https://github.com/TypeStrong/ts-node) options (lookup docs of those packages):
2426
```
25-
ts-node-dev --fast --respawn server.ts
27+
ts-node-dev --respawn server.ts
2628
```
2729

2830
Also there is additional options specific to `ts-node-dev`:
2931

3032
- `--compile-timeout` (default: 10000 ms) - for how long to wait before report the error that something went wrong with compilation of a file.
3133
- `--prefer-ts` (default: false) - for each `.js` file (that is not in `node_modules`) will try to check if corresponding `.ts` version exists and require it.
32-
- `--ignore-watch` (default: []) - files/folders to be [ignored by `node-dev`](https://github.com/fgnass/node-dev#ignore-paths). **Note that it will resolve this directories/files relative to cwd** mapping each value to single directory/file.
34+
- `--ignore-watch` (default: []) - files/folders to be [ignored by `node-dev`](https://github.com/fgnass/node-dev#ignore-paths).
35+
**But also this behaviour enhanced:** it will also make up `new RegExp` of passed ignore string and check absolute paths of required files for match.
36+
So, to ignore everthing in `node_modules`, just pass `--ignore-watch node_modules`
3337

3438

3539
By defalut to keep things clean it puts cached files to system temp directory, you may change this with `--cache-directory` option.

bin/ts-node-dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var opts = minimist(devArgs, {
1111
stopEarly: true,
1212
boolean: [
1313
'all-deps', 'deps', 'dedupe', 'poll', 'respawn', 'notify',
14-
'fast', 'disableWarnings', 'no-cache',
14+
'fast', 'disableWarnings', 'no-cache', 'cache', 'type-check',
1515
'prefer-ts'
1616
],
1717
string: [

lib/cfg.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ module.exports = function (main, opts) {
2929
if (opts.respawn) c.respawn = true;
3030
if (opts.notify === false) c.notify = false;
3131
}
32-
33-
var ignore = (c.ignore || [])
34-
.concat(opts && opts['ignore-watch'] || [])
35-
.map(resolvePath);
32+
33+
var ignoreWatch = (c.ignore || []).concat(opts && opts['ignore-watch'] || []);
34+
ignoreWatch.length && console.log('Ignore watch:', ignoreWatch)
35+
var ignore = ignoreWatch.concat(ignoreWatch.map(resolvePath));
3636

3737
return {
3838
vm: c.vm !== false,

lib/compiler.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ var compiler = {
6262
var tsNodeOptions = {
6363
fast: options['fast'],
6464
cache: options['cache'] || !options['no-cache'],
65+
typeCheck: options['type-check'],
6566
cacheDirectory: options['cache-directory'] || path.join(tmpDir, 'cache'),
6667
compiler: options['compiler'],
6768
project: options['project'],

lib/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module.exports = function (script, scriptArgs, nodeArgs, opts) {
7171
env: process.env
7272
});
7373
if (!compiler.tsConfigPath) {
74-
throw('Check existance of tsconfig.json file.')
74+
throw new Error('Check existance of tsconfig.json file.')
7575
}
7676
watcher.add(compiler.tsConfigPath);
7777

@@ -84,9 +84,9 @@ module.exports = function (script, scriptArgs, nodeArgs, opts) {
8484
child = undefined;
8585
});
8686

87-
// Listen for `required` messages and watch the required file.
87+
// Listen for `required` messages and watch the required file.
8888
ipc.on(child, 'required', function (m) {
89-
var isIgnored = cfg.ignore.some(isPrefixOf(m.required));
89+
var isIgnored = cfg.ignore.some(isPrefixOf(m.required)) || cfg.ignore.some(isRegExpMatch(m.required));
9090

9191
if (!isIgnored && (cfg.deps === -1 || getLevel(m.required) <= cfg.deps)) {
9292
watcher.add(m.required);
@@ -140,3 +140,9 @@ function isPrefixOf(value) {
140140
return value.indexOf(prefix) === 0;
141141
};
142142
}
143+
144+
function isRegExpMatch(value) {
145+
return function (regExp) {
146+
return (new RegExp(regExp)).test(value);
147+
};
148+
}

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-node-dev",
3-
"version": "1.0.0-pre.5",
3+
"version": "1.0.0-pre.7",
44
"description": "Compiles your TS app and restarts when files are modified.",
55
"keywords": [
66
"restart",
@@ -33,7 +33,7 @@
3333
},
3434
"scripts": {
3535
"test-node-dev": "tap test/*.js",
36-
"test": "node ./bin/ts-node-dev -r ./test/ts/add-require.js --respawn --ignore-watch lib --ignore-watch bin --prefer-ts --cache-directory .ts-node test/ts/test-script test-arg --fd"
36+
"test": "node ./bin/ts-node-dev -r ./test/ts/add-require.js --cache --respawn --ignore-watch lib --ignore-watch bin --prefer-ts --cache-directory .ts-node test/ts/test-script test-arg --fd"
3737
},
3838
"dependencies": {
3939
"dateformat": "~1.0.4-1.2.3",
@@ -42,8 +42,7 @@
4242
"minimist": "^1.1.3",
4343
"node-notifier": "^4.0.2",
4444
"resolve": "^1.0.0",
45-
"rimraf": "^2.6.1",
46-
"ts-node": "^3.0.6"
45+
"rimraf": "^2.6.1"
4746
},
4847
"devDependencies": {
4948
"@types/node": "^8.0.4",

test/ts/dep.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const fn = () => {
1+
export const fn = () => {
22
console.log('function from dep module here')
33
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"compilerOptions": {
33
"allowJs": false
44
}

0 commit comments

Comments
 (0)