Skip to content

Commit

Permalink
chore(tests): fix libnpmdiff tests for execPaths with spaces (#4988)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlf committed Jun 14, 2022
1 parent b46fed7 commit 253671d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions workspaces/libnpmdiff/test/index.js
Expand Up @@ -5,11 +5,12 @@ const t = require('tap')
const diff = require('../lib/index.js')

const normalizePath = p => p
.replace(/\\+/g, '/')
.replace(/\\+(?!")/g, '/')
.replace(/\r\n/g, '\n')

t.cleanSnapshot = (str) => normalizePath(str)
.replace(normalizePath(process.execPath), 'node')
.replace(/\\"node\\"/g, 'node')

const json = (obj) => `${JSON.stringify(obj, null, 2)}\n`

Expand Down Expand Up @@ -62,7 +63,7 @@ t.test('folder in node_modules', async t => {
name: 'a',
version: '1.0.0',
scripts: {
prepare: `${process.execPath} prepare.js`,
prepare: `"${process.execPath}" prepare.js`,
},
}),
'prepare.js': 'throw new Error("ERR")',
Expand All @@ -72,7 +73,7 @@ t.test('folder in node_modules', async t => {
name: 'b',
version: '2.0.0',
scripts: {
prepare: `${process.execPath} prepare.js`,
prepare: `"${process.execPath}" prepare.js`,
},
}),
'prepare.js': 'throw new Error("ERR")',
Expand All @@ -86,7 +87,7 @@ t.test('folder in node_modules', async t => {
name: 'a',
version: '1.0.1',
scripts: {
prepare: `${process.execPath} prepare.js`,
prepare: `"${process.execPath}" prepare.js`,
},
}),
'prepare.js': '',
Expand All @@ -96,7 +97,7 @@ t.test('folder in node_modules', async t => {
name: 'b',
version: '2.0.1',
scripts: {
prepare: `${process.execPath} prepare.js`,
prepare: `"${process.execPath}" prepare.js`,
},
}),
'prepare.js': '',
Expand Down

0 comments on commit 253671d

Please sign in to comment.