From 7a1bc86b976105d9282216ea6c9e6e4161d2a644 Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Mon, 26 Feb 2018 22:35:29 +0000 Subject: [PATCH 1/2] fix: make it possible for windows to checkout Fixes #1255 --- test/fixtures/some 'file | 3 - "test/fixtures/some \\file" | 3 - test/fixtures/some file | 2 - "test/fixtures/some\"file" | 2 - "test/fixtures/some\\\"file" | 3 - test/fork/run-mac-only.test.js | 82 ++++++++++++++++++++++ test/fork/run.test.js | 124 +++++++++------------------------ 7 files changed, 114 insertions(+), 105 deletions(-) delete mode 100755 test/fixtures/some 'file delete mode 100755 "test/fixtures/some \\file" delete mode 100755 test/fixtures/some file delete mode 100755 "test/fixtures/some\"file" delete mode 100755 "test/fixtures/some\\\"file" create mode 100644 test/fork/run-mac-only.test.js diff --git a/test/fixtures/some 'file b/test/fixtures/some 'file deleted file mode 100755 index 82f9a804..00000000 --- a/test/fixtures/some 'file +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -echo "OK" \ No newline at end of file diff --git "a/test/fixtures/some \\file" "b/test/fixtures/some \\file" deleted file mode 100755 index 010db579..00000000 --- "a/test/fixtures/some \\file" +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -echo "OK" diff --git a/test/fixtures/some file b/test/fixtures/some file deleted file mode 100755 index 427c4722..00000000 --- a/test/fixtures/some file +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -console.log('OK'); \ No newline at end of file diff --git "a/test/fixtures/some\"file" "b/test/fixtures/some\"file" deleted file mode 100755 index 6f47df84..00000000 --- "a/test/fixtures/some\"file" +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -console.log('OK'); diff --git "a/test/fixtures/some\\\"file" "b/test/fixtures/some\\\"file" deleted file mode 100755 index 010db579..00000000 --- "a/test/fixtures/some\\\"file" +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -echo "OK" diff --git a/test/fork/run-mac-only.test.js b/test/fork/run-mac-only.test.js new file mode 100644 index 00000000..51620900 --- /dev/null +++ b/test/fork/run-mac-only.test.js @@ -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); + } + }); + }); + }); +} diff --git a/test/fork/run.test.js b/test/fork/run.test.js index 5b6e63d4..c572e562 100644 --- a/test/fork/run.test.js +++ b/test/fork/run.test.js @@ -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) { @@ -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') { @@ -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') { @@ -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') { @@ -173,4 +113,4 @@ describe('nodemon fork', function () { } }); }); -}); \ No newline at end of file +}); From dec6d053d174205244d3667950e4062ce9058019 Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Tue, 27 Feb 2018 08:10:57 +0000 Subject: [PATCH 2/2] chore: fix es5 tests --- test/fork/run-mac-only.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fork/run-mac-only.test.js b/test/fork/run-mac-only.test.js index 51620900..9ce3a7d6 100644 --- a/test/fork/run-mac-only.test.js +++ b/test/fork/run-mac-only.test.js @@ -12,11 +12,11 @@ const filenames = [ if (!process.env.TRAVIS && process.platform !== 'win32') { describe('nodemon fork (mac only)', () => { before(() => { - filenames.map(([filename, contents]) => fs.writeFileSync(filename, contents, 'utf8')); + filenames.map(file => fs.writeFileSync(file[0], file[1], 'utf8')); }); after(() => { - filenames.map(([filename]) => fs.unlinkSync(filename)); + filenames.map(file => fs.unlinkSync(file[0])); }); it('should start a fork exec with quotes and escaping', done => {