Skip to content

Commit 9d2cfcf

Browse files
committed
Fishrock's suggestion
1 parent 4c6280d commit 9d2cfcf

13 files changed

+27
-49
lines changed

test/parallel/test-child-process-default-options.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ var assert = require('assert');
44

55
var spawn = require('child_process').spawn;
66

7-
var isWindows = common.isWindows;
8-
97
process.env.HELLO = 'WORLD';
108

11-
if (isWindows) {
9+
if (common.isWindows) {
1210
var child = spawn('cmd.exe', ['/c', 'set'], {});
1311
} else {
1412
var child = spawn('/usr/bin/env', [], {});

test/parallel/test-child-process-env.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ var assert = require('assert');
44

55
var spawn = require('child_process').spawn;
66

7-
var isWindows = common.isWindows;
8-
97
var env = {
108
'HELLO': 'WORLD'
119
};
1210
env.__proto__ = {
1311
'FOO': 'BAR'
1412
};
1513

16-
if (isWindows) {
14+
if (common.isWindows) {
1715
var child = spawn('cmd.exe', ['/c', 'set'], {env: env});
1816
} else {
1917
var child = spawn('/usr/bin/env', [], {env: env});

test/parallel/test-child-process-kill.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ var assert = require('assert');
44

55
var spawn = require('child_process').spawn;
66

7-
var is_windows = common.isWindows;
8-
97
var exitCode;
108
var termSignal;
119
var gotStdoutEOF = false;
1210
var gotStderrEOF = false;
1311

14-
var cat = spawn(is_windows ? 'cmd' : 'cat');
12+
var cat = spawn(common.isWindows ? 'cmd' : 'cat');
1513

1614

1715
cat.stdout.on('end', function() {

test/parallel/test-child-process-stdin.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ var common = require('../common');
33
var assert = require('assert');
44

55
var spawn = require('child_process').spawn;
6-
var is_windows = common.isWindows;
76

8-
var cat = spawn(is_windows ? 'more' : 'cat');
7+
var cat = spawn(common.isWindows ? 'more' : 'cat');
98
cat.stdin.write('hello');
109
cat.stdin.write(' ');
1110
cat.stdin.write('world');
@@ -51,7 +50,7 @@ cat.on('exit', function(status) {
5150

5251
cat.on('close', function() {
5352
closed = true;
54-
if (is_windows) {
53+
if (common.isWindows) {
5554
assert.equal('hello world\r\n', response);
5655
} else {
5756
assert.equal('hello world', response);
@@ -61,7 +60,7 @@ cat.on('close', function() {
6160
process.on('exit', function() {
6261
assert.equal(0, exitStatus);
6362
assert(closed);
64-
if (is_windows) {
63+
if (common.isWindows) {
6564
assert.equal('hello world\r\n', response);
6665
} else {
6766
assert.equal('hello world', response);

test/parallel/test-fs-chmod.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ var got_error = false;
77
var success_count = 0;
88
var mode_async;
99
var mode_sync;
10-
var is_windows = common.isWindows;
1110

1211
// Need to hijack fs.open/close to make sure that things
1312
// get closed once they're opened.
@@ -44,7 +43,7 @@ function closeSync() {
4443

4544

4645
// On Windows chmod is only able to manipulate read-only bit
47-
if (is_windows) {
46+
if (common.isWindows) {
4847
mode_async = 0o400; // read-only
4948
mode_sync = 0o600; // read-write
5049
} else {
@@ -61,14 +60,14 @@ fs.chmod(file1, mode_async.toString(8), function(err) {
6160
} else {
6261
console.log(fs.statSync(file1).mode);
6362

64-
if (is_windows) {
63+
if (common.isWindows) {
6564
assert.ok((fs.statSync(file1).mode & 0o777) & mode_async);
6665
} else {
6766
assert.equal(mode_async, fs.statSync(file1).mode & 0o777);
6867
}
6968

7069
fs.chmodSync(file1, mode_sync);
71-
if (is_windows) {
70+
if (common.isWindows) {
7271
assert.ok((fs.statSync(file1).mode & 0o777) & mode_sync);
7372
} else {
7473
assert.equal(mode_sync, fs.statSync(file1).mode & 0o777);
@@ -89,14 +88,14 @@ fs.open(file2, 'a', function(err, fd) {
8988
} else {
9089
console.log(fs.fstatSync(fd).mode);
9190

92-
if (is_windows) {
91+
if (common.isWindows) {
9392
assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_async);
9493
} else {
9594
assert.equal(mode_async, fs.fstatSync(fd).mode & 0o777);
9695
}
9796

9897
fs.fchmodSync(fd, mode_sync);
99-
if (is_windows) {
98+
if (common.isWindows) {
10099
assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_sync);
101100
} else {
102101
assert.equal(mode_sync, fs.fstatSync(fd).mode & 0o777);

test/parallel/test-fs-realpath.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ var fs = require('fs');
55
var path = require('path');
66
var exec = require('child_process').exec;
77
var async_completed = 0, async_expected = 0, unlink = [];
8-
var isWindows = common.isWindows;
98
var skipSymlinks = false;
109

1110
common.refreshTmpDir();
1211

1312
var root = '/';
14-
if (isWindows) {
13+
if (common.isWindows) {
1514
// something like "C:\\"
1615
root = process.cwd().substr(0, 3);
1716

@@ -292,7 +291,7 @@ function test_relative_input_cwd(callback) {
292291

293292
function test_deep_symlink_mix(callback) {
294293
console.log('test_deep_symlink_mix');
295-
if (isWindows) {
294+
if (common.isWindows) {
296295
// This one is a mix of files and directories, and it's quite tricky
297296
// to get the file/dir links sorted out correctly.
298297
console.log('1..0 # Skipped: symlink test (no privs)');
@@ -503,7 +502,7 @@ function test_lying_cache_liar(cb) {
503502
'/a/b' : '/a/b',
504503
'/a/b/c' : '/a/b',
505504
'/a/b/d' : '/a/b/d' };
506-
if (isWindows) {
505+
if (common.isWindows) {
507506
var wc = {};
508507
Object.keys(cache).forEach(function(k) {
509508
wc[ path.resolve(k) ] = path.resolve(cache[k]);

test/parallel/test-fs-symlink.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ var expected_async = 4;
99
var linkTime;
1010
var fileTime;
1111

12-
var is_windows = common.isWindows;
13-
1412
common.refreshTmpDir();
1513

1614
var runtest = function(skip_symlinks) {
@@ -57,7 +55,7 @@ var runtest = function(skip_symlinks) {
5755
});
5856
};
5957

60-
if (is_windows) {
58+
if (common.isWindows) {
6159
// On Windows, creating symlinks requires admin privileges.
6260
// We'll only try to run symlink test if we have enough privileges.
6361
exec('whoami /priv', function(err, o) {

test/parallel/test-fs-utimes.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ var assert = require('assert');
44
var util = require('util');
55
var fs = require('fs');
66

7-
var is_windows = common.isWindows;
8-
97
var tests_ok = 0;
108
var tests_run = 0;
119

@@ -99,7 +97,7 @@ function runTest(atime, mtime, callback) {
9997
expect_errno('utimes', 'foobarbaz', err, 'ENOENT');
10098

10199
// don't close this fd
102-
if (is_windows) {
100+
if (common.isWindows) {
103101
fd = fs.openSync(__filename, 'r+');
104102
} else {
105103
fd = fs.openSync(__filename, 'r');

test/parallel/test-fs-write-file-sync.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ var common = require('../common');
33
var assert = require('assert');
44
var path = require('path');
55
var fs = require('fs');
6-
var isWindows = common.isWindows;
76
var openCount = 0;
87
var mode;
98
var content;
@@ -20,7 +19,7 @@ var mask = process.umask(0o000);
2019

2120
// On Windows chmod is only able to manipulate read-only bit. Test if creating
2221
// the file in read-only mode works.
23-
if (isWindows) {
22+
if (common.isWindows) {
2423
mode = 0o444;
2524
} else {
2625
mode = 0o755;

test/parallel/test-module-globalpaths-nodepath.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ var assert = require('assert');
44

55
var module = require('module');
66

7-
var isWindows = common.isWindows;
8-
97
var partA, partB;
108
var partC = '';
119

12-
if (isWindows) {
10+
if (common.isWindows) {
1311
partA = 'C:\\Users\\Rocko Artischocko\\AppData\\Roaming\\npm';
1412
partB = 'C:\\Program Files (x86)\\nodejs\\';
1513
process.env['NODE_PATH'] = partA + ';' + partB + ';' + partC;

0 commit comments

Comments
 (0)