Skip to content

Commit bb39180

Browse files
committed
Merge pull request #101 from fgnass/release-2.7.0
2.7.0
2 parents fd18d05 + bcf361c commit bb39180

8 files changed

Lines changed: 95 additions & 37 deletions

File tree

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# node-dev
2+
3+
## 2.7.0 / 2015-08-17
4+
5+
- [#88]: Support ignoring file paths, e.g. for universal (isomorphic) apps. See
6+
[`README`][README-ignore-paths] for more details.
7+
- Use [`commander`][npm-commander] for CLI argument parsing instead of custom code.
8+
- Extract [`LICENSE`][LICENSE] file.
9+
- Upgrade [`tap`][npm-tap] module to 1.3.2.
10+
- Use [`touch`][npm-touch] module instead of custom code.
11+
12+
13+
[LICENSE]: LICENSE
14+
[npm-commander]: https://www.npmjs.com/package/commander
15+
[npm-tap]: https://www.npmjs.com/package/tap
16+
[npm-touch]: https://www.npmjs.com/package/touch
17+
[README]: README.md
18+
[README-ignore-paths]: README.md#ignore-paths
19+
20+
[#88]: https://github.com/fgnass/node-dev/issues/88

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2014–2015 Felix Gnass
4+
Copyright (c) 2015 Daniel Gasienica
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

README.md

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -145,28 +145,7 @@ server restart when changed, since it introduces an unnecessary delay.
145145

146146
## License
147147

148-
### The MIT License (MIT)
149-
150-
Copyright (c) 2014–2015 Felix Gnass
151-
Copyright (c) 2015 Daniel Gasienica
152-
153-
Permission is hereby granted, free of charge, to any person obtaining a copy
154-
of this software and associated documentation files (the "Software"), to deal
155-
in the Software without restriction, including without limitation the rights
156-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
157-
copies of the Software, and to permit persons to whom the Software is
158-
furnished to do so, subject to the following conditions:
159-
160-
The above copyright notice and this permission notice shall be included in
161-
all copies or substantial portions of the Software.
162-
163-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
164-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
165-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
166-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
167-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
168-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
169-
THE SOFTWARE.
148+
MIT
170149

171150

172151
[react]: http://facebook.github.io/react/

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-dev",
3-
"version": "2.6.2",
3+
"version": "2.7.0",
44
"description": "Restarts your app when files are modified",
55
"keywords": [
66
"restart",
@@ -39,6 +39,7 @@
3939
},
4040
"devDependencies": {
4141
"coffee-script": "^1.8.0",
42-
"tap": "^0.4.13"
42+
"tap": "^1.3.2",
43+
"touch": "^1.0.0"
4344
}
4445
}

test/fixture/.node-dev.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"notify": false
3-
}
2+
"notify": false,
3+
"ignore": [
4+
"./ignoredModule.js"
5+
]
6+
}

test/fixture/ignoredModule.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "Ignored file — `touch`ing it should not restart server."

test/fixture/server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var http = require('http')
22
, message = require('./message')
3+
// Changes to this module should not cause a server restart:
4+
, ignoredModule = require('./ignoredModule')
35

46
var server = http.createServer(function (req, res) {
57
res.writeHead(200, {'Content-Type': 'text/plain'})

test/index.js

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
var fs = require('fs')
22
, child = require('child_process')
33
, test = require('tap').test
4+
, touch = require('touch')
45

56
var dir = __dirname + '/fixture'
67
, bin = __dirname + '/../bin/node-dev'
78
, msgFile = dir + '/message.js'
8-
, msg = 'module.exports = "Please touch message.js now"\n'
9+
, ignoredFile = dir + '/ignoredModule.js'
910

10-
function touch() {
11-
fs.writeFileSync(msgFile, msg)
11+
12+
// Constants
13+
var MESSAGE = fs.readFileSync(msgFile).toString()
14+
15+
// Helpers
16+
function touchFile(file) {
17+
return function() {
18+
touch.sync(file ? file : msgFile)
19+
}
1220
}
1321

1422
function spawn(cmd, cb) {
@@ -31,7 +39,7 @@ function spawn(cmd, cb) {
3139
function run(cmd, done) {
3240
spawn(cmd, function(out) {
3341
if (out.match(/touch message.js/)) {
34-
setTimeout(touch, 500)
42+
setTimeout(touchFile(), 500)
3543
return function(out) {
3644
if (out.match(/Restarting/)) {
3745
return { exit: done }
@@ -41,18 +49,18 @@ function run(cmd, done) {
4149
})
4250
}
4351

44-
52+
// Tests
4553
test('should restart the server', function(t) {
4654
run('server.js', t.end.bind(t))
4755
})
4856

4957
test('should restart the server twice', function(t) {
5058
spawn('server.js', function(out) {
5159
if (out.match(/touch message.js/)) {
52-
setTimeout(touch, 500)
60+
setTimeout(touchFile(), 500)
5361
return function(out) {
5462
if (out.match(/Restarting/)) {
55-
setTimeout(touch, 500)
63+
setTimeout(touchFile(), 500)
5664
return function(out) {
5765
if (out.match(/Restarting/)) {
5866
return { exit: t.end.bind(t) }
@@ -64,6 +72,28 @@ test('should restart the server twice', function(t) {
6472
})
6573
})
6674

75+
test('should not restart the server for ignored modules', function(t) {
76+
ps = spawn('server.js', function(out) {
77+
if (out.match(/touch message.js/)) {
78+
setTimeout(touchFile(ignoredFile), 500)
79+
80+
var successTimeoutId = setTimeout(function () {
81+
ps.removeAllListeners('exit')
82+
ps.kill()
83+
84+
t.end()
85+
}, 1000);
86+
87+
return function(out) {
88+
clearTimeout(successTimeoutId)
89+
t.fail('server restarted unexpectedly')
90+
91+
return { exit: t.end.bind(t) }
92+
}
93+
}
94+
})
95+
})
96+
6797
test('should restart the cluster', function(t) {
6898
run('cluster.js', t.end.bind(t))
6999
})
@@ -78,7 +108,7 @@ test('should support coffee-script', function(t) {
78108

79109
test('should restart when a file is renamed', function(t) {
80110
var tmp = dir + '/message.tmp'
81-
fs.writeFileSync(tmp, msg)
111+
fs.writeFileSync(tmp, MESSAGE)
82112
spawn('log.js', function(out) {
83113
if (out.match(/touch message.js/)) {
84114
fs.renameSync(tmp, msgFile)
@@ -94,7 +124,7 @@ test('should restart when a file is renamed', function(t) {
94124
test('should handle errors', function(t) {
95125
spawn('error.js', function(out) {
96126
if (out.match(/ERROR/)) {
97-
setTimeout(touch, 500)
127+
setTimeout(touchFile(), 500)
98128
return function(out) {
99129
if (out.match(/Restarting/)) {
100130
return { exit: t.end.bind(t) }
@@ -135,7 +165,7 @@ test('should pass through the exit code', function(t) {
135165
})
136166
})
137167

138-
test('should conceil the wrapper', function(t) {
168+
test('should conceal the wrapper', function(t) {
139169
// require.main should be main.js not wrap.js!
140170
spawn('main.js').on('exit', function(code) {
141171
t.is(code, 0)
@@ -177,7 +207,7 @@ test('should set NODE_ENV', function(t) {
177207
test('should allow graceful shutdowns', function(t) {
178208
spawn('server.js', function(out) {
179209
if (out.match(/touch message.js/)) {
180-
setTimeout(touch, 500)
210+
setTimeout(touchFile(), 500)
181211
return function(out) {
182212
if (out.match(/exit/)) {
183213
return { exit: t.end.bind(t) }

0 commit comments

Comments
 (0)