Skip to content

Commit c0c0927

Browse files
committed
fix: replace deprecated module.parent with require.main === module in examples
1 parent 6c4249f commit c0c0927

File tree

24 files changed

+31
-31
lines changed

24 files changed

+31
-31
lines changed

examples/auth/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ hash({ password: 'foobar' }, function (err, pass, salt, hash) {
5858
// Authenticate using our plain-object database of doom!
5959

6060
function authenticate(name, pass, fn) {
61-
if (!module.parent) console.log('authenticating %s:%s', name, pass);
61+
if (require.main === module) console.log('authenticating %s:%s', name, pass);
6262
var user = users[name];
6363
// query the db for the given username
6464
if (!user) return fn(null, null)
@@ -128,7 +128,7 @@ app.post('/login', function (req, res, next) {
128128
});
129129

130130
/* istanbul ignore next */
131-
if (!module.parent) {
131+
if (require.main === module) {
132132
app.listen(3000);
133133
console.log('Express started on port 3000');
134134
}

examples/content-negotiation/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function format(path) {
4040
app.get('/users', format('./users'));
4141

4242
/* istanbul ignore next */
43-
if (!module.parent) {
43+
if (require.main === module) {
4444
app.listen(3000);
4545
console.log('Express started on port 3000');
4646
}

examples/cookie-sessions/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ app.get('/', function (req, res) {
1919
})
2020

2121
/* istanbul ignore next */
22-
if (!module.parent) {
22+
if (require.main === module) {
2323
app.listen(3000);
2424
console.log('Express started on port 3000');
2525
}

examples/cookies/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ app.post('/', function(req, res){
4747
});
4848

4949
/* istanbul ignore next */
50-
if (!module.parent) {
50+
if (require.main === module) {
5151
app.listen(3000);
5252
console.log('Express started on port 3000');
5353
}

examples/downloads/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ app.get('/files/*file', function (req, res, next) {
3434
});
3535

3636
/* istanbul ignore next */
37-
if (!module.parent) {
37+
if (require.main === module) {
3838
app.listen(3000);
3939
console.log('Express started on port 3000');
4040
}

examples/ejs/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ app.get('/', function(req, res){
5151
});
5252

5353
/* istanbul ignore next */
54-
if (!module.parent) {
54+
if (require.main === module) {
5555
app.listen(3000);
5656
console.log('Express started on port 3000');
5757
}

examples/error-pages/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ app.use(function(err, req, res, next){
9797
});
9898

9999
/* istanbul ignore next */
100-
if (!module.parent) {
100+
if (require.main === module) {
101101
app.listen(3000);
102102
console.log('Express started on port 3000');
103103
}

examples/error/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ app.get('/next', function(req, res, next){
4747
app.use(error);
4848

4949
/* istanbul ignore next */
50-
if (!module.parent) {
50+
if (require.main === module) {
5151
app.listen(3000);
5252
console.log('Express started on port 3000');
5353
}

examples/hello-world/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ app.get('/', function(req, res){
99
});
1010

1111
/* istanbul ignore next */
12-
if (!module.parent) {
12+
if (require.main === module) {
1313
app.listen(3000);
1414
console.log('Express started on port 3000');
1515
}

examples/markdown/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ app.get('/fail', function(req, res){
3838
});
3939

4040
/* istanbul ignore next */
41-
if (!module.parent) {
41+
if (require.main === module) {
4242
app.listen(3000);
4343
console.log('Express started on port 3000');
4444
}

0 commit comments

Comments
 (0)