Skip to content

Commit 16c9b8b

Browse files
committed
Ensure method patching works when filename arguments are missing
1 parent 985efc7 commit 16c9b8b

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 3.1.2 / 2016-05-28
44

55
- Proof against weird `require.extensions`. See #134.
6+
- Ensure method patching works when filename arguments are missing. See #135.
67

78
## 3.1.1 / 2016-05-02
89

test/fixture/vmtest.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ var fs = require('fs');
33
var file = __dirname + '/log.js';
44
var str = fs.readFileSync(file, 'utf8');
55

6-
vm.runInNewContext(str, { module: {}, require: require, console: console }, file);
6+
if(process.argv.length > 2 && process.argv[2] === 'nofile') {
7+
vm.runInNewContext(str, { module: {}, require: require, console: console });
8+
} else {
9+
vm.runInNewContext(str, { module: {}, require: require, console: console }, file);
10+
}
711

812
// Listen for events to keep running
913
process.on('message', function () {});

test/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ test('should support vm functions', function (t) {
132132
run('vmtest.js', t.end.bind(t));
133133
});
134134

135+
test('should support vm functions with missing file argument', function (t) {
136+
run('vmtest.js nofile', t.end.bind(t));
137+
});
138+
135139
test('should support coffee-script', function (t) {
136140
run('server.coffee', t.end.bind(t));
137141
});

0 commit comments

Comments
 (0)