Skip to content

Commit

Permalink
fix: make it possible for windows to checkout
Browse files Browse the repository at this point in the history
Fixes #1255
  • Loading branch information
remy committed Feb 26, 2018
1 parent 1cda8fa commit 7a1bc86
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 105 deletions.
3 changes: 0 additions & 3 deletions test/fixtures/some 'file

This file was deleted.

3 changes: 0 additions & 3 deletions test/fixtures/some \file

This file was deleted.

2 changes: 0 additions & 2 deletions test/fixtures/some file

This file was deleted.

2 changes: 0 additions & 2 deletions test/fixtures/some"file

This file was deleted.

3 changes: 0 additions & 3 deletions test/fixtures/some\"file

This file was deleted.

82 changes: 82 additions & 0 deletions test/fork/run-mac-only.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
const fs = require('fs');
const assert = require('assert');
const utils = require('../utils');
const appJS = utils.appjs;
const run = utils.run;

const filenames = [
[__dirname + 'some\\\"file', '#!/usr/bin/env node\nconsole.log("OK");'],
[__dirname + 'some\ \\file', '#!/bin/sh\necho "OK"'],
];

if (!process.env.TRAVIS && process.platform !== 'win32') {
describe('nodemon fork (mac only)', () => {
before(() => {
filenames.map(([filename, contents]) => fs.writeFileSync(filename, contents, 'utf8'));
});

after(() => {
filenames.map(([filename]) => fs.unlinkSync(filename));
});

it('should start a fork exec with quotes and escaping', done => {
var found = false;
var p = run({
exec: 'bin/nodemon.js',
// make nodemon verbose so we can check the filters being applied
args: ['-q', '--exec', filenames[0][0]]
}, {
error: function (data) {
p.send('quit');
done(new Error(data));
},
output: function (data) {
// process.stdout.write(data);
if (data.trim() === 'OK') {
found = true;
}
}
});

p.on('message', function (event) {
if (event.type === 'start') {
setTimeout(function () {
p.send('quit');
done();
assert(found, '"OK" message was found');
}, 500);
}
});
});

it('should start a fork exec with spaces and slashes', done => {
var found = false;
var p = run({
exec: 'bin/nodemon.js',
// make nodemon verbose so we can check the filters being applied
args: ['-q', '--exec', `"${filenames[1][0]}`]
}, {
error: function (data) {
p.send('quit');
done(new Error(data));
},
output: function (data) {
// process.stdout.write(data);
if (data.trim() === 'OK') {
found = true;
}
}
});

p.on('message', function (event) {
if (event.type === 'start') {
setTimeout(function () {
p.send('quit');
done();
assert(found, '"OK" message was found');
}, 500);
}
});
});
});
}
124 changes: 32 additions & 92 deletions test/fork/run.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*global describe:true, it: true */
var assert = require('assert'),
utils = require('../utils'),
appjs = utils.appjs,
run = utils.run;
utils = require('../utils'),
appjs = utils.appjs,
run = utils.run;

describe('nodemon fork', function () {
it('should start a fork', function (done) {
Expand Down Expand Up @@ -30,77 +30,17 @@ describe('nodemon fork', function () {
// make nodemon verbose so we can check the filters being applied
args: ['-q', '--exec', 'test/fixtures/app\\ with\\ spaces.js']
}, {
error: function (data) {
p.send('quit');
done(new Error(data));
},
output: function (data) {
// process.stdout.write(data);
if (data.trim() === 'OK') {
found = true;
}
}
});

p.on('message', function (event) {
if (event.type === 'start') {
setTimeout(function () {
error: function (data) {
p.send('quit');
done();
assert(found, '"OK" message was found');
}, 500);
}
});
});

it('should start a fork exec with quotes and escaping', function (done) {
var found = false;
var p = run({
exec: 'bin/nodemon.js',
// make nodemon verbose so we can check the filters being applied
args: ['-q', '--exec', 'test/fixtures/some\\\"file']
}, {
error: function (data) {
p.send('quit');
done(new Error(data));
},
output: function (data) {
// process.stdout.write(data);
if (data.trim() === 'OK') {
found = true;
done(new Error(data));
},
output: function (data) {
// process.stdout.write(data);
if (data.trim() === 'OK') {
found = true;
}
}
}
});

p.on('message', function (event) {
if (event.type === 'start') {
setTimeout(function () {
p.send('quit');
done();
assert(found, '"OK" message was found');
}, 500);
}
});
});

it('should start a fork exec with spaces and slashes', function (done) {
var found = false;
var p = run({
exec: 'bin/nodemon.js',
// make nodemon verbose so we can check the filters being applied
args: ['-q', '--exec', '"test/fixtures/some\ \\file"']
}, {
error: function (data) {
p.send('quit');
done(new Error(data));
},
output: function (data) {
// process.stdout.write(data);
if (data.trim() === 'OK') {
found = true;
}
}
});
});

p.on('message', function (event) {
if (event.type === 'start') {
Expand All @@ -120,16 +60,16 @@ describe('nodemon fork', function () {
// make nodemon verbose so we can check the filters being applied
args: ['-q', '--exec', '"test/fixtures/app with spaces.js" foo'],
}, {
error: function (data) {
p.send('quit');
done(new Error(data));
},
output: function (data) {
if (data.trim() === 'foo') {
found = true;
error: function (data) {
p.send('quit');
done(new Error(data));
},
output: function (data) {
if (data.trim() === 'foo') {
found = true;
}
}
}
});
});

p.on('message', function (event) {
if (event.type === 'start') {
Expand All @@ -151,17 +91,17 @@ describe('nodemon fork', function () {
// make nodemon verbose so we can check the filters being applied
args: ['-q', '--exec', 'test/fixtures/app\\ with\\ spaces.js foo']
}, {
error: function (data) {
p.send('quit');
done(new Error(data));
},
output: function (data) {
// process.stdout.write(data);
if (data.trim() === 'foo') {
found = true;
error: function (data) {
p.send('quit');
done(new Error(data));
},
output: function (data) {
// process.stdout.write(data);
if (data.trim() === 'foo') {
found = true;
}
}
}
});
});

p.on('message', function (event) {
if (event.type === 'start') {
Expand All @@ -173,4 +113,4 @@ describe('nodemon fork', function () {
}
});
});
});
});

0 comments on commit 7a1bc86

Please sign in to comment.