-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Validates vercel build deps
- Loading branch information
Showing
5 changed files
with
155 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
const args = process.argv.splice(2); | ||
for (let i = 0; i < args.length; i += 2) { | ||
const key = args[i]; | ||
const value = args[i + 1]; | ||
if (!value) { | ||
console.warn('missing arg value for', key); | ||
continue; | ||
} | ||
|
||
console.log('assigning arg to env', key, value); | ||
process.env[key] = value; | ||
} | ||
|
||
require('../dist'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const { exec } = require('child_process'); | ||
const { access, unlink } = require('fs/promises'); | ||
const path = require('path'); | ||
|
||
const exists = async (path) => { | ||
try { | ||
await access(path); | ||
return true; | ||
} | ||
catch { | ||
return false; | ||
} | ||
}; | ||
|
||
/** | ||
* @param {string} path | ||
*/ | ||
const unlinkIfExistsAsync = async (path) => { | ||
if (await exists(path)) { | ||
unlink(path); | ||
} | ||
}; | ||
|
||
describe('e2e', () => { | ||
before(async () => { | ||
const promises = ['./basic.exe', './with-plugins.exe'] | ||
.map(unlinkIfExistsAsync); | ||
|
||
await Promise.all(promises); | ||
}); | ||
|
||
/** | ||
* @typedef {{ | ||
* customArguments?: string, | ||
* additionalPluginPaths?: string[], | ||
* scriptFile?: string, | ||
* }} RunOptions | ||
* @param {RunOptions} options | ||
*/ | ||
const run = async (options = {}) => { | ||
const { | ||
customArguments, | ||
additionalPluginPaths, | ||
scriptFile | ||
} = options; | ||
|
||
const args = []; | ||
const env = { | ||
...process.env, | ||
debug: 'true', | ||
}; | ||
if (customArguments) { | ||
args.push('INPUT_ARGUMENTS', customArguments); | ||
} | ||
if (additionalPluginPaths && additionalPluginPaths.length) { | ||
args.push('INPUT_ADDITIONAL-PLUGIN-PATHS', additionalPluginPaths.join('\n')); | ||
} | ||
if (scriptFile) { | ||
args.push('INPUT_SCRIPT-FILE', scriptFile); | ||
} | ||
|
||
const programPath = require.resolve('./bootstrap'); | ||
const testDir = path.dirname(programPath); | ||
const cwd = path.join(testDir, '../'); | ||
const promise = new Promise((resolve, reject) => { | ||
exec(`node ${programPath} ${args.join(' ')}`, { | ||
env, | ||
cwd, | ||
}, (error, stdout, stderr) => { | ||
console.log('cwd', cwd); | ||
console.log('stdout', stdout); | ||
console.log('stderr', stderr); | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
|
||
await promise; | ||
}; | ||
|
||
/** | ||
* @param {string} script | ||
* @param {(options: RunOptions) => void} fn | ||
*/ | ||
const test = (script, fn) => { | ||
it(`should create installer for ${script}.nsi`, async () => { | ||
const options = { | ||
scriptFile: `./test/${script}.nsi` | ||
}; | ||
if (fn) { | ||
fn(options); | ||
} | ||
|
||
await run(options); | ||
|
||
const actual = await exists(`./test/${script}.exe`); | ||
|
||
assert( | ||
actual, | ||
`Installer \`./test/${script}.exe\` should exist` | ||
); | ||
}); | ||
}; | ||
|
||
test('basic'); | ||
test('with-plugins', options => options.additionalPluginPaths = [ | ||
'./test/EnVar' | ||
]); | ||
}); |