diff --git a/test/commands.js b/test/commands.js index 79b3e12..f3987c4 100644 --- a/test/commands.js +++ b/test/commands.js @@ -9,527 +9,563 @@ import { platform } from 'os'; import test from 'ava'; // Generate script using compiler flags -const nullDevice = (platform() === 'win32') - ? 'NUL' - : '/dev/null'; +const nullDevice = platform() === 'win32' ? 'NUL' : '/dev/null'; const defaultScriptArray = [ - `OutFile ${nullDevice}`, - `Unicode true`, - `Section -default`, - `Nop`, - `SectionEnd` + `OutFile ${nullDevice}`, + `Unicode true`, + `Section -default`, + `Nop`, + `SectionEnd`, ]; const defaultScriptString = defaultScriptArray.join('\n'); const scriptFile = { - minimal: join(__dirname, 'fixtures', 'utf8.nsi'), - warning: join(__dirname, 'fixtures', 'warnings.nsi') + minimal: join(__dirname, 'fixtures', 'utf8.nsi'), + warning: join(__dirname, 'fixtures', 'warnings.nsi'), }; // Expected values -const commandHelp = spawnSync('makensis', ['-CMDHELP']).stdout.toString().trim() || spawnSync('makensis', ['-CMDHELP']).stderr.toString().trim(); +const commandHelp = + spawnSync('makensis', ['-CMDHELP']).stdout.toString().trim() || + spawnSync('makensis', ['-CMDHELP']).stderr.toString().trim(); const headerInfo = spawnSync('makensis', ['-HDRINFO']).stdout.toString().trim(); -const outFile = spawnSync('makensis', ['-CMDHELP', 'OutFile']).stdout.toString().trim() || spawnSync('makensis', ['-CMDHELP', 'OutFile']).stderr.toString().trim(); +const outFile = + spawnSync('makensis', ['-CMDHELP', 'OutFile']).stdout.toString().trim() || + spawnSync('makensis', ['-CMDHELP', 'OutFile']).stderr.toString().trim(); const license = spawnSync('makensis', ['-LICENSE']).stdout.toString().trim(); const version = spawnSync('makensis', ['-VERSION']).stdout.toString().trim(); // Let's run the tests -test(`MakeNSIS ${version} found in PATH environmental variable`, t => { - const which = (platform() === 'win32') - ? 'where' - : 'which'; - const actual = spawnSync(which, ['makensis']).stdout.toString().trim(); +test(`MakeNSIS ${version} found in PATH environmental variable`, (t) => { + const which = platform() === 'win32' ? 'where' : 'which'; + const actual = spawnSync(which, ['makensis']).stdout.toString().trim(); - t.not(actual, ''); + t.not(actual, ''); }); -test('Print makensis version', t => { - const expected = version; - const actual = MakeNSIS.versionSync().stdout; +test('Print makensis version', (t) => { + const expected = version; + const actual = MakeNSIS.versionSync().stdout; - t.is(actual, expected); + t.is(actual, expected); }); -test('Print makensis version as JSON', t => { - let expected = version; - let actual = MakeNSIS.versionSync({ json: true }).stdout; +test('Print makensis version as JSON', (t) => { + let expected = version; + let actual = MakeNSIS.versionSync({ json: true }).stdout; - if (expected.startsWith('v')) { - expected = expected.substr(1); - } + if (expected.startsWith('v')) { + expected = expected.substr(1); + } - actual = JSON.stringify(actual); - expected = JSON.stringify({ version: expected }); + actual = JSON.stringify(actual); + expected = JSON.stringify({ version: expected }); - t.is(actual, expected); + t.is(actual, expected); }); test('Print makensis version [async]', async (t) => { - try { - const { stdout } = await MakeNSIS.version(); + try { + const { stdout } = await MakeNSIS.version(); - const expected = version; - const actual = stdout; + const expected = version; + const actual = stdout; - t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); test('Print makensis version as JSON [async]', async (t) => { - try { - const { stdout } = await MakeNSIS.version({ json: true }); + try { + const { stdout } = await MakeNSIS.version({ json: true }); - let expected = version; + let expected = version; - if (expected.startsWith('v')) { - expected = expected.substr(1); - } + if (expected.startsWith('v')) { + expected = expected.substr(1); + } - expected = JSON.stringify({ version: expected }); + expected = JSON.stringify({ version: expected }); - let actual = stdout; - actual.version = `${actual.version}`; - actual = JSON.stringify(actual); + let actual = stdout; + actual.version = `${actual.version}`; + actual = JSON.stringify(actual); - t.is(actual, expected); - - } catch({ stderr }) { - t.fail(stderr); - } + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); -test('Print makensis license', t => { - let expected = license; - let actual = MakeNSIS.licenseSync().stdout; +test('Print makensis license', (t) => { + let expected = license; + let actual = MakeNSIS.licenseSync().stdout; - t.is(actual, expected); + t.is(actual, expected); }); -test('Print makensis license as JSON', t => { - let expected = license; - let actual = MakeNSIS.licenseSync({ json: true }).stdout; +test('Print makensis license as JSON', (t) => { + let expected = license; + let actual = MakeNSIS.licenseSync({ json: true }).stdout; - actual = JSON.stringify(actual); - expected = JSON.stringify({ license: expected }); + actual = JSON.stringify(actual); + expected = JSON.stringify({ license: expected }); - t.is(actual, expected); + t.is(actual, expected); }); test('Print makensis license [async]', async (t) => { - try { - const { stdout } = await MakeNSIS.license(); + try { + const { stdout } = await MakeNSIS.license(); - const expected = license; - const actual = stdout; + const expected = license; + const actual = stdout; - t.is(actual, expected); - - } catch ({ stdout }) { - // NSIS < 3.03 - t.log('Legacy NSIS'); - const expected = license; - const actual = stdout; + t.is(actual, expected); + } catch ({ stdout }) { + // NSIS < 3.03 + t.log('Legacy NSIS'); + const expected = license; + const actual = stdout; - t.is(actual, expected); - } + t.is(actual, expected); + } }); test('Print makensis license as JSON [async]', async (t) => { - try { - const { stdout } = await MakeNSIS.license({ json: true }); + try { + const { stdout } = await MakeNSIS.license({ json: true }); - let expected = license; - expected = JSON.stringify({ license: expected }); + let expected = license; + expected = JSON.stringify({ license: expected }); - let actual = stdout; - actual.license = `${actual.license}`; - actual = JSON.stringify(actual); + let actual = stdout; + actual.license = `${actual.license}`; + actual = JSON.stringify(actual); - t.is(actual, expected); - } catch ({ stdout }) { - // NSIS < 3.03 - t.log('Legacy NSIS'); - let expected = license; - expected = JSON.stringify({ license: expected }); + t.is(actual, expected); + } catch ({ stdout }) { + // NSIS < 3.03 + t.log('Legacy NSIS'); + let expected = license; + expected = JSON.stringify({ license: expected }); - let actual = stdout; - actual.license = `${actual.license}`; - actual = JSON.stringify(actual); + let actual = stdout; + actual.license = `${actual.license}`; + actual = JSON.stringify(actual); - t.is(actual, expected); - } + t.is(actual, expected); + } }); -test('Print compiler information', t => { - const expected = headerInfo; - const actual = MakeNSIS.headerInfoSync().stdout; +test('Print compiler information', (t) => { + const expected = headerInfo; + const actual = MakeNSIS.headerInfoSync().stdout; - t.is(actual, expected); + t.is(actual, expected); }); -test('Print compiler information as JSON', t => { - const expected = true; - const actual = MakeNSIS.headerInfoSync({ json: true }).stdout.defined_symbols.__GLOBAL__; +test('Print compiler information as JSON', (t) => { + const expected = true; + const actual = MakeNSIS.headerInfoSync({ json: true }).stdout + .defined_symbols.__GLOBAL__; - t.is(actual, expected); + t.is(actual, expected); }); test('Print compiler information [async]', async (t) => { - try { - const { stdout } = await MakeNSIS.headerInfo(); + try { + const { stdout } = await MakeNSIS.headerInfo(); - const expected = headerInfo; - const actual = stdout; + const expected = headerInfo; + const actual = stdout; - t.is(actual, expected); - } catch ({ stdout }) { - // NSIS < 3.03 - t.log('Legacy NSIS'); - const expected = headerInfo; - const actual = stdout; + t.is(actual, expected); + } catch ({ stdout }) { + // NSIS < 3.03 + t.log('Legacy NSIS'); + const expected = headerInfo; + const actual = stdout; - t.is(actual, expected); - } + t.is(actual, expected); + } }); -test('Print help for all commands', t => { - const expected = commandHelp; - const actual = MakeNSIS.commandHelpSync().stdout; +test('Print help for all commands', (t) => { + const expected = commandHelp; + const actual = MakeNSIS.commandHelpSync().stdout; - t.is(actual, expected); + t.is(actual, expected); }); test('Print help for all commands [async]', async (t) => { - return Promise.resolve(MakeNSIS.commandHelp()) - .then(output => { - const expected = commandHelp.replace(/\s+/g, ''); - const actual = output.stdout.replace(/\s+/g, ''); + return Promise.resolve(MakeNSIS.commandHelp()) + .then((output) => { + const expected = commandHelp.replace(/\s+/g, ''); + const actual = output.stdout.replace(/\s+/g, ''); - t.is(actual, expected); - }) - .catch(({stdout}) => { - // NSIS < 3.03 - t.log('Legacy NSIS'); - const expected = commandHelp.replace(/\s+/g, ''); - const actual = stdout.replace(/\s+/g, ''); + t.is(actual, expected); + }) + .catch(({ stdout }) => { + // NSIS < 3.03 + t.log('Legacy NSIS'); + const expected = commandHelp.replace(/\s+/g, ''); + const actual = stdout.replace(/\s+/g, ''); - t.is(actual, expected); - }); + t.is(actual, expected); + }); }); -test('Print help for OutFile command', t => { - const expected = outFile; - const actual = MakeNSIS.commandHelpSync('OutFile').stdout; +test('Print help for OutFile command', (t) => { + const expected = outFile; + const actual = MakeNSIS.commandHelpSync('OutFile').stdout; - t.is(actual, expected); + t.is(actual, expected); }); test('Print help for OutFile command [async]', async (t) => { - try { - const { stdout } = await MakeNSIS.commandHelp('OutFile'); + try { + const { stdout } = await MakeNSIS.commandHelp('OutFile'); - const expected = outFile; - const actual = stdout; + const expected = outFile; + const actual = stdout; - t.is(actual, expected); - } catch ({ stdout }) { - // NSIS < 3.03 - t.log('Legacy NSIS'); - const expected = outFile; - const actual = stdout; + t.is(actual, expected); + } catch ({ stdout }) { + // NSIS < 3.03 + t.log('Legacy NSIS'); + const expected = outFile; + const actual = stdout; - t.is(actual, expected); - } + t.is(actual, expected); + } }); -test('Print help for OutFile command as JSON', t => { - let expected = outFile; - let actual = MakeNSIS.commandHelpSync('OutFile', { json: true }).stdout; +test('Print help for OutFile command as JSON', (t) => { + let expected = outFile; + let actual = MakeNSIS.commandHelpSync('OutFile', { json: true }).stdout; - actual = JSON.stringify(actual); - expected = JSON.stringify({'help': expected }); + actual = JSON.stringify(actual); + expected = JSON.stringify({ help: expected }); - t.is(actual, expected); + t.is(actual, expected); }); -test('Compilation from File', t => { - const expected = 0; - const actual = MakeNSIS.compileSync(scriptFile.minimal, { - define: { - 'NULL_DEVICE': nullDevice - } - }).status; +test('Compilation from File', (t) => { + const expected = 0; + const actual = MakeNSIS.compileSync(scriptFile.minimal, { + define: { + NULL_DEVICE: nullDevice, + }, + }).status; - t.is(actual, expected); + t.is(actual, expected); }); -test('Compilation from Array', t => { - const expected = 0; - const actual = MakeNSIS.compileSync(null, { preExecute: defaultScriptArray }).status; +test('Compilation from Array', (t) => { + const expected = 0; + const actual = MakeNSIS.compileSync(null, { + preExecute: defaultScriptArray, + }).status; - t.is(actual, expected); + t.is(actual, expected); }); -test('Compilation from String', t => { - const expected = 0; - const actual = MakeNSIS.compileSync(null, { preExecute: defaultScriptString }).status; +test('Compilation from String', (t) => { + const expected = 0; + const actual = MakeNSIS.compileSync(null, { + preExecute: defaultScriptString, + }).status; - t.is(actual, expected); + t.is(actual, expected); }); test('Compilation from File [async]', async (t) => { - try { - const { status } = await MakeNSIS.compile(scriptFile.minimal, { - define: { - 'NULL_DEVICE': nullDevice - } - }); - - const expected = 0; - const actual = status; - - t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } + try { + const { status } = await MakeNSIS.compile(scriptFile.minimal, { + define: { + NULL_DEVICE: nullDevice, + }, + }); + + const expected = 0; + const actual = status; + + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); test('Compilation from Array [async]', async (t) => { - try { - const { status } = await MakeNSIS.compile(null, { preExecute: defaultScriptString }); + try { + const { status } = await MakeNSIS.compile(null, { + preExecute: defaultScriptString, + }); - const expected = 0; - const actual = status; + const expected = 0; + const actual = status; - t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); test('Compilation from String [async]', async (t) => { - try { - const { status } = await MakeNSIS.compile(null, { preExecute: defaultScriptString }); + try { + const { status } = await MakeNSIS.compile(null, { + preExecute: defaultScriptString, + }); - const expected = 0; - const actual = status; + const expected = 0; + const actual = status; - t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); -test('Compilation with warning', t => { - const scriptWithWarning = [...defaultScriptArray, '!warning']; +test('Compilation with warning', (t) => { + const scriptWithWarning = [...defaultScriptArray, '!warning']; - const expected = 0; - const actual = MakeNSIS.compileSync(null, { preExecute: scriptWithWarning }).status; + const expected = 0; + const actual = MakeNSIS.compileSync(null, { preExecute: scriptWithWarning }) + .status; - t.is(actual, expected); + t.is(actual, expected); }); -test('Compilation with warning as JSON', t => { - const expected = 1; - const scriptWithWarning = [...defaultScriptArray, '!warning']; - const actual = MakeNSIS.compileSync(null, { preExecute: scriptWithWarning, json: true }).warnings; +test('Compilation with warning as JSON', (t) => { + const expected = 1; + const scriptWithWarning = [...defaultScriptArray, '!warning']; + const actual = MakeNSIS.compileSync(null, { + preExecute: scriptWithWarning, + json: true, + }).warnings; - t.is(actual, expected); + t.is(actual, expected); }); test('Compilation with warning [async]', async (t) => { - const scriptWithWarning = [...defaultScriptArray, '!warning']; + const scriptWithWarning = [...defaultScriptArray, '!warning']; - try { - const { status } = await MakeNSIS.compile(null, { preExecute: scriptWithWarning }); + try { + const { status } = await MakeNSIS.compile(null, { + preExecute: scriptWithWarning, + }); - const expected = 0; - const actual = status; + const expected = 0; + const actual = status; - t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); test('Compilation with warning as JSON [async]', async (t) => { - const scriptWithWarning = [...defaultScriptArray, '!warning']; + const scriptWithWarning = [...defaultScriptArray, '!warning']; - try { - const { warnings } = await MakeNSIS.compile(null, { preExecute: scriptWithWarning, json: true }); + try { + const { warnings } = await MakeNSIS.compile(null, { + preExecute: scriptWithWarning, + json: true, + }); - const expected = 1; - const actual = warnings; + const expected = 1; + const actual = warnings; - t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); -test('Compilation with error', t => { - const scriptWithError = [...defaultScriptArray, '!error']; +test('Compilation with error', (t) => { + const scriptWithError = [...defaultScriptArray, '!error']; - const expected = 0; - const actual = MakeNSIS.compileSync(null, { preExecute: scriptWithError }).status; + const expected = 0; + const actual = MakeNSIS.compileSync(null, { preExecute: scriptWithError }) + .status; - t.not(actual, expected); + t.not(actual, expected); }); -test('Compilation with raw arguments string', t => { - const expected = ''; - const actual = MakeNSIS.compileSync(scriptFile.minimal, { rawArguments: '-V0' }).stdout; +test('Compilation with raw arguments string', (t) => { + const expected = ''; + const actual = MakeNSIS.compileSync(scriptFile.minimal, { + rawArguments: '-V0', + }).stdout; - t.is(actual, expected); + t.is(actual, expected); }); test('Compilation with raw arguments string [async]', async (t) => { - try { - const { status } = await MakeNSIS.compile(scriptFile.minimal, { rawArguments: '-V0', define: { - 'NULL_DEVICE': nullDevice - }}); - - const expected = 0; - const actual = status; - - t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } + try { + const { status } = await MakeNSIS.compile(scriptFile.minimal, { + rawArguments: '-V0', + define: { + NULL_DEVICE: nullDevice, + }, + }); + + const expected = 0; + const actual = status; + + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); -test('Compilation with raw arguments array', t => { - const expected = ''; - const actual = MakeNSIS.compileSync(scriptFile.minimal, { rawArguments: ['-V0'] }).stdout; +test('Compilation with raw arguments array', (t) => { + const expected = ''; + const actual = MakeNSIS.compileSync(scriptFile.minimal, { + rawArguments: ['-V0'], + }).stdout; - t.is(actual, expected); + t.is(actual, expected); }); test('Compilation with raw arguments array [async]', async (t) => { - try { - const { status } = await MakeNSIS.compile(scriptFile.minimal, { rawArguments: '-V0', define: { - 'NULL_DEVICE': nullDevice - }}); - - const expected = 0; - const actual = status; - - t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } + try { + const { status } = await MakeNSIS.compile(scriptFile.minimal, { + rawArguments: '-V0', + define: { + NULL_DEVICE: nullDevice, + }, + }); + + const expected = 0; + const actual = status; + + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); -test('Compilation with raw arguments string and warning', t => { - const expected = 1; - const actual = MakeNSIS.compileSync(scriptFile.warning, { rawArguments: '-WX' }).status; +test('Compilation with raw arguments string and warning', (t) => { + const expected = 1; + const actual = MakeNSIS.compileSync(scriptFile.warning, { + rawArguments: '-WX', + }).status; - t.is(actual, expected); + t.is(actual, expected); }); test('Compilation with raw arguments string and warning [async]', async (t) => { - try { - const { status } = await MakeNSIS.compile(scriptFile.warning, { rawArguments: '-WX' }); + try { + const { status } = await MakeNSIS.compile(scriptFile.warning, { + rawArguments: '-WX', + }); - const expected = 1; - const actual = status; + const expected = 1; + const actual = status; - t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); test('Compilation with error [async]', async (t) => { - let scriptWithError = [...defaultScriptArray, '!error']; + let scriptWithError = [...defaultScriptArray, '!error']; - try { - const { status } = await MakeNSIS.compile(null, { preExecute: scriptWithError}); + try { + const { status } = await MakeNSIS.compile(null, { + preExecute: scriptWithError, + }); - const expected = 0; - const actual = status; + const expected = 0; + const actual = status; - t.not(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } -}); - -test('Strict compilation with warning', t => { - const scriptWithWarning = [...defaultScriptArray, '!warning']; - - const expected = 0; - const actual = MakeNSIS.compileSync(null, { preExecute: scriptWithWarning, strict: true }).status; - - t.not(actual, expected); + t.not(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); -test('Strict compilation with warning [async]', async (t) => { - const scriptWithWarning = [...defaultScriptArray, '!warning']; - - try { - const { status } = await MakeNSIS.compile(null, { preExecute: scriptWithWarning, strict: true }); +test('Strict compilation with warning', (t) => { + const scriptWithWarning = [...defaultScriptArray, '!warning']; const expected = 0; - const actual = status; + const actual = MakeNSIS.compileSync(null, { + preExecute: scriptWithWarning, + strict: true, + }).status; t.not(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } }); -test('Print ${NSISDIR}', t => { - const nsisDir = MakeNSIS.nsisDirSync(); - const nsisCfg = join(nsisDir, 'Include', 'MUI2.nsh'); +test('Strict compilation with warning [async]', async (t) => { + const scriptWithWarning = [...defaultScriptArray, '!warning']; - const expected = true; - const actual = existsSync(nsisCfg); + try { + const { status } = await MakeNSIS.compile(null, { + preExecute: scriptWithWarning, + strict: true, + }); - t.is(actual, expected); -}); + const expected = 0; + const actual = status; -test('Print ${NSISDIR} [async]', async (t) => { + t.not(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } +}); - try { - const nsisDir = await MakeNSIS.nsisDir(); +test('Print ${NSISDIR}', (t) => { + const nsisDir = MakeNSIS.nsisDirSync(); const nsisCfg = join(nsisDir, 'Include', 'MUI2.nsh'); const expected = true; const actual = existsSync(nsisCfg); t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } - - }); -test('Print ${NSISDIR} as JSON', t => { - const nsisDir = MakeNSIS.nsisDirSync({ json: true }).nsisdir; - const nsisCfg = join(nsisDir, 'Include', 'MUI2.nsh'); +test('Print ${NSISDIR} [async]', async (t) => { + try { + const nsisDir = await MakeNSIS.nsisDir(); + const nsisCfg = join(nsisDir, 'Include', 'MUI2.nsh'); - const expected = true; - const actual = existsSync(nsisCfg); + const expected = true; + const actual = existsSync(nsisCfg); - t.is(actual, expected); + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); -test('Print ${NSISDIR} as JSON [async]', async (t) => { - try { - const nsisDir = await MakeNSIS.nsisDir({ json: true }); - const nsisCfg = join(nsisDir.nsisdir, 'Include', 'MUI2.nsh'); +test('Print ${NSISDIR} as JSON', (t) => { + const nsisDir = MakeNSIS.nsisDirSync({ json: true }).nsisdir; + const nsisCfg = join(nsisDir, 'Include', 'MUI2.nsh'); const expected = true; const actual = existsSync(nsisCfg); t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } +}); + +test('Print ${NSISDIR} as JSON [async]', async (t) => { + try { + const nsisDir = await MakeNSIS.nsisDir({ json: true }); + const nsisCfg = join(nsisDir.nsisdir, 'Include', 'MUI2.nsh'); + + const expected = true; + const actual = existsSync(nsisCfg); + + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); diff --git a/test/encoding.js b/test/encoding.js index 46c6aa4..2452319 100644 --- a/test/encoding.js +++ b/test/encoding.js @@ -8,68 +8,68 @@ import test from 'ava'; // Compiler arguments const script = { - // cp850: join(__dirname, 'fixtures', 'cp850.nsi'), - utf8: join(__dirname, 'fixtures', 'utf8.nsi') -} -const nullDevice = (platform() === 'win32') ? 'NUL' : '/dev/null'; + // cp850: join(__dirname, 'fixtures', 'cp850.nsi'), + utf8: join(__dirname, 'fixtures', 'utf8.nsi'), +}; +const nullDevice = platform() === 'win32' ? 'NUL' : '/dev/null'; let options = { - strict: true, - define: { - 'NULL_DEVICE': nullDevice - } -} + strict: true, + define: { + NULL_DEVICE: nullDevice, + }, +}; // Let's run the tests -test('Compile script with correct charset', t => { - options = { ...options, inputCharset: 'UTF8' }; +test('Compile script with correct charset', (t) => { + options = { ...options, inputCharset: 'UTF8' }; - const expected = ''; - const actual = compileSync(script['utf8'], options).stderr; + const expected = ''; + const actual = compileSync(script['utf8'], options).stderr; - t.is(actual, expected); + t.is(actual, expected); }); -test('Compile script with incorrect charset', t => { - options = { ...options, inputCharset: 'UTF16BE' }; +test('Compile script with incorrect charset', (t) => { + options = { ...options, inputCharset: 'UTF16BE' }; - const expected = 0; - const actual = compileSync(script['utf8'], options).status; + const expected = 0; + const actual = compileSync(script['utf8'], options).status; - t.not(actual, expected); + t.not(actual, expected); }); test('Compile script with correct charset [async]', async (t) => { - options = { ...options, inputCharset: 'UTF8' }; + options = { ...options, inputCharset: 'UTF8' }; - try { - const { status } = await compile(script['utf8'], options); + try { + const { status } = await compile(script['utf8'], options); - const expected = 0; - const actual = status; + const expected = 0; + const actual = status; - t.is(actual, expected) - } catch ({ stderr }) { - // NSIS < 3.03 - t.log('Legacy NSIS'); + t.is(actual, expected); + } catch ({ stderr }) { + // NSIS < 3.03 + t.log('Legacy NSIS'); - const expected = ''; - const actual = stderr; + const expected = ''; + const actual = stderr; - t.is(actual, expected) - } + t.is(actual, expected); + } }); test('Compile script with incorrect charset [async]', async (t) => { - options = { ...options, inputCharset: 'UTF16BE' }; + options = { ...options, inputCharset: 'UTF16BE' }; - try { - const { status } = compile(script['utf8'], options); + try { + const { status } = compile(script['utf8'], options); - const expected = 0; - const actual = status; + const expected = 0; + const actual = status; - t.not(actual, expected) - } catch ({ stderr }) { - t.fail(stderr); - } + t.not(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); diff --git a/test/wine.js b/test/wine.js index 6559362..614f34d 100644 --- a/test/wine.js +++ b/test/wine.js @@ -9,541 +9,627 @@ import { platform } from 'os'; import test from 'ava'; // Generate script using compiler flags -const nullDevice = (platform() === 'win32') ? 'NUL' : '/dev/null'; +const nullDevice = platform() === 'win32' ? 'NUL' : '/dev/null'; const defaultScriptArray = [ - `OutFile ${nullDevice}`, - `Unicode true`, - `Section -default`, - `Nop`, - `SectionEnd` + `OutFile ${nullDevice}`, + `Unicode true`, + `Section -default`, + `Nop`, + `SectionEnd`, ]; const defaultScriptString = defaultScriptArray.join('\n'); const scriptFile = { - minimal: join(__dirname, 'fixtures', 'utf8.nsi'), - warning: join(__dirname, 'fixtures', 'warnings.nsi') + minimal: join(__dirname, 'fixtures', 'utf8.nsi'), + warning: join(__dirname, 'fixtures', 'warnings.nsi'), }; // These test require NSIS to be setup properly, with makensis in your // PATH environmental variable -test('Wine found in PATH environmental variable', t => { - const actual = spawnSync('which', ['wine']).stdout.toString().trim(); +test('Wine found in PATH environmental variable', (t) => { + const actual = spawnSync('which', ['wine']).stdout.toString().trim(); - t.not(actual, ''); + t.not(actual, ''); }); // Expected values -const commandHelp = spawnSync('wine', ['makensis', '-CMDHELP']).stdout.toString().trim().replace(/\r\n/g, '\n'); -const headerInfo = spawnSync('wine', ['makensis', '-HDRINFO']).stdout.toString().trim(); -const outFile = spawnSync('wine', ['makensis', '-CMDHELP', 'OutFile']).stdout.toString().trim().replace(/\r\n/g, '\n'); -const license = spawnSync('wine', ['makensis', '-LICENSE']).stdout.toString().trim(); -const version = spawnSync('wine', ['makensis', '-VERSION']).stdout.toString().trim(); - -test('Print makensis version', t => { - const expected = version; - const actual = MakeNSIS.versionSync({ wine: true }).stdout; - - t.is(actual, expected); -}); - -test('Print makensis version as JSON', t => { - let expected = version; - let actual = MakeNSIS.versionSync({ wine: true, json: true }).stdout; - - if (expected.startsWith('v')) { - expected = expected.substr(1); - } - - actual = JSON.stringify(actual); - expected = JSON.stringify({ version: expected }); - - t.is(actual, expected); -}); - -test('Print makensis version [async]', t => { - return Promise.resolve(MakeNSIS.version({ wine: true })) - .then(output => { +const commandHelp = spawnSync('wine', ['makensis', '-CMDHELP']) + .stdout.toString() + .trim() + .replace(/\r\n/g, '\n'); +const headerInfo = spawnSync('wine', ['makensis', '-HDRINFO']) + .stdout.toString() + .trim(); +const outFile = spawnSync('wine', ['makensis', '-CMDHELP', 'OutFile']) + .stdout.toString() + .trim() + .replace(/\r\n/g, '\n'); +const license = spawnSync('wine', ['makensis', '-LICENSE']) + .stdout.toString() + .trim(); +const version = spawnSync('wine', ['makensis', '-VERSION']) + .stdout.toString() + .trim(); + +test('Print makensis version', (t) => { const expected = version; - const actual = output.stdout; + const actual = MakeNSIS.versionSync({ wine: true }).stdout; t.is(actual, expected); - }) - .catch(error => { - t.fail(error); - }); }); -test('Print makensis version as JSON [async]', t => { - return Promise.resolve(MakeNSIS.version({ wine: true, json: true })) - .then(output => { +test('Print makensis version as JSON', (t) => { let expected = version; + let actual = MakeNSIS.versionSync({ wine: true, json: true }).stdout; if (expected.startsWith('v')) { - expected = expected.substr(1); + expected = expected.substr(1); } - expected = JSON.stringify({ version: expected }); - let actual = output.stdout; - actual.version = `${actual.version}`; actual = JSON.stringify(actual); + expected = JSON.stringify({ version: expected }); t.is(actual, expected); - }) - .catch(error => { - t.fail(error); - }); }); -test('Print makensis license', t => { - let expected = license; - let actual = MakeNSIS.licenseSync({ wine: true }).stdout; +test('Print makensis version [async]', (t) => { + return Promise.resolve(MakeNSIS.version({ wine: true })) + .then((output) => { + const expected = version; + const actual = output.stdout; - t.is(actual, expected); + t.is(actual, expected); + }) + .catch((error) => { + t.fail(error); + }); }); -test('Print makensis license as JSON', t => { - let expected = license; - let actual = MakeNSIS.licenseSync({ wine: true, json: true }).stdout; +test('Print makensis version as JSON [async]', (t) => { + return Promise.resolve(MakeNSIS.version({ wine: true, json: true })) + .then((output) => { + let expected = version; - actual = JSON.stringify(actual); - expected = JSON.stringify({ license: expected }); + if (expected.startsWith('v')) { + expected = expected.substr(1); + } + expected = JSON.stringify({ version: expected }); - t.is(actual, expected); -}); + let actual = output.stdout; + actual.version = `${actual.version}`; + actual = JSON.stringify(actual); -test('Print makensis license [async]', t => { - return Promise.resolve(MakeNSIS.license({ wine: true })) - .then(output => { - const expected = license; - const actual = output.stdout; + t.is(actual, expected); + }) + .catch((error) => { + t.fail(error); + }); +}); - t.is(actual, expected); - }) - .catch(output => { - // NSIS < 3.03 - t.log('Legacy NSIS'); - const expected = license; - const actual = output.stdout; +test('Print makensis license', (t) => { + let expected = license; + let actual = MakeNSIS.licenseSync({ wine: true }).stdout; t.is(actual, expected); - }); }); -test('Print makensis license as JSON [async]', t => { - return Promise.resolve(MakeNSIS.license({ wine: true, json: true })) - .then(output => { +test('Print makensis license as JSON', (t) => { let expected = license; - expected = JSON.stringify({ license: expected }); + let actual = MakeNSIS.licenseSync({ wine: true, json: true }).stdout; - let actual = output.stdout; - actual.license = `${actual.license}`; actual = JSON.stringify(actual); - - t.is(actual, expected); - }) - .catch(output => { - // NSIS < 3.03 - t.log('Legacy NSIS'); - let expected = license; expected = JSON.stringify({ license: expected }); - let actual = output.stdout; - actual.license = `${actual.license}`; - actual = JSON.stringify(actual); - t.is(actual, expected); - }); }); -test('Print compiler information', t => { - const expected = headerInfo; - const actual = MakeNSIS.headerInfoSync({ wine: true }).stdout; +test('Print makensis license [async]', (t) => { + return Promise.resolve(MakeNSIS.license({ wine: true })) + .then((output) => { + const expected = license; + const actual = output.stdout; - t.is(actual, expected); + t.is(actual, expected); + }) + .catch((output) => { + // NSIS < 3.03 + t.log('Legacy NSIS'); + const expected = license; + const actual = output.stdout; + + t.is(actual, expected); + }); }); -test('Print compiler information as JSON', t => { - const expected = true; - const actual = MakeNSIS.headerInfoSync({ wine: true, json: true }).stdout.defined_symbols.__GLOBAL__; +test('Print makensis license as JSON [async]', (t) => { + return Promise.resolve(MakeNSIS.license({ wine: true, json: true })) + .then((output) => { + let expected = license; + expected = JSON.stringify({ license: expected }); + + let actual = output.stdout; + actual.license = `${actual.license}`; + actual = JSON.stringify(actual); - t.is(actual, expected); + t.is(actual, expected); + }) + .catch((output) => { + // NSIS < 3.03 + t.log('Legacy NSIS'); + let expected = license; + expected = JSON.stringify({ license: expected }); + + let actual = output.stdout; + actual.license = `${actual.license}`; + actual = JSON.stringify(actual); + + t.is(actual, expected); + }); }); -test('Print compiler information [async]', t => { - return Promise.resolve(MakeNSIS.headerInfo({ wine: true })) - .then(output => { +test('Print compiler information', (t) => { const expected = headerInfo; - const actual = output.stdout; + const actual = MakeNSIS.headerInfoSync({ wine: true }).stdout; t.is(actual, expected); - }) - .catch(output => { - // NSIS < 3.03 - t.log('Legacy NSIS'); - const expected = headerInfo; - const actual = output.stdout; +}); + +test('Print compiler information as JSON', (t) => { + const expected = true; + const actual = MakeNSIS.headerInfoSync({ wine: true, json: true }).stdout + .defined_symbols.__GLOBAL__; t.is(actual, expected); - }); }); -test('Print help for all commands', t => { - const expected = commandHelp; - const actual = MakeNSIS.commandHelpSync({ wine: true }).stdout; +test('Print compiler information [async]', (t) => { + return Promise.resolve(MakeNSIS.headerInfo({ wine: true })) + .then((output) => { + const expected = headerInfo; + const actual = output.stdout; - t.is(actual, expected); + t.is(actual, expected); + }) + .catch((output) => { + // NSIS < 3.03 + t.log('Legacy NSIS'); + const expected = headerInfo; + const actual = output.stdout; + + t.is(actual, expected); + }); }); -test('Print help for all commands [async]', t => { - return Promise.resolve(MakeNSIS.commandHelp({ wine: true })) - .then(output => { +test('Print help for all commands', (t) => { const expected = commandHelp; - const actual = output.stdout; + const actual = MakeNSIS.commandHelpSync({ wine: true }).stdout; t.is(actual, expected); - }) - .catch(output => { - // NSIS < 3.03 - t.log('Legacy NSIS'); - const expected = commandHelp; - const actual = output.stdout; - - t.is(actual, expected); - }); }); -test('Print help for OutFile command', t => { - const expected = outFile; - const actual = MakeNSIS.commandHelpSync('OutFile', { wine: true }).stdout; +test('Print help for all commands [async]', (t) => { + return Promise.resolve(MakeNSIS.commandHelp({ wine: true })) + .then((output) => { + const expected = commandHelp; + const actual = output.stdout; - t.is(actual, expected); -}); + t.is(actual, expected); + }) + .catch((output) => { + // NSIS < 3.03 + t.log('Legacy NSIS'); + const expected = commandHelp; + const actual = output.stdout; -test('Print help for OutFile command [async]', t => { - return Promise.resolve(MakeNSIS.commandHelp('OutFile', { wine: true })) - .then(output => { - const expected = outFile; - const actual = output.stdout; + t.is(actual, expected); + }); +}); - t.is(actual, expected); - }) - .catch(output => { - // NSIS < 3.03 - t.log('Legacy NSIS'); +test('Print help for OutFile command', (t) => { const expected = outFile; - const actual = output.stdout; + const actual = MakeNSIS.commandHelpSync('OutFile', { wine: true }).stdout; t.is(actual, expected); - }); }); -test('Print help for OutFile command as JSON', t => { - let expected = outFile; - let actual = MakeNSIS.commandHelpSync('OutFile', { wine: true, json: true }).stdout; +test('Print help for OutFile command [async]', (t) => { + return Promise.resolve(MakeNSIS.commandHelp('OutFile', { wine: true })) + .then((output) => { + const expected = outFile; + const actual = output.stdout; - actual = JSON.stringify(actual); - expected = JSON.stringify({'help': expected }); + t.is(actual, expected); + }) + .catch((output) => { + // NSIS < 3.03 + t.log('Legacy NSIS'); + const expected = outFile; + const actual = output.stdout; - t.is(actual, expected); + t.is(actual, expected); + }); }); -test('Compilation from File', t => { - const expected = 0; - const actual = MakeNSIS.compileSync(scriptFile.minimal, { - wine: true, - define: { - 'NULL_DEVICE': nullDevice - } - }).status; - - t.is(actual, expected); -}); +test('Print help for OutFile command as JSON', (t) => { + let expected = outFile; + let actual = MakeNSIS.commandHelpSync('OutFile', { wine: true, json: true }) + .stdout; -test('Compilation from Array', t => { - const expected = 0; - const actual = MakeNSIS.compileSync(null, { wine: true, preExecute: defaultScriptArray }).status; - - t.is(actual, expected); -}); - -test('Compilation from String', t => { - const expected = 0; - const actual = MakeNSIS.compileSync(null, { wine: true, preExecute: defaultScriptString }).status; + actual = JSON.stringify(actual); + expected = JSON.stringify({ help: expected }); - t.is(actual, expected); + t.is(actual, expected); }); -test('Compilation from File [async]', async (t) => { - try { - const { status } = await MakeNSIS.compile(scriptFile.minimal, { - wine: true, - define: { - 'NULL_DEVICE': nullDevice - } - }); - +test('Compilation from File', (t) => { const expected = 0; - const actual = status; + const actual = MakeNSIS.compileSync(scriptFile.minimal, { + wine: true, + define: { + NULL_DEVICE: nullDevice, + }, + }).status; t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } }); -test('Compilation from Array [async]', t => { - return Promise.resolve(MakeNSIS.compile(null, { wine: true, preExecute: defaultScriptArray })) - .then(output => { +test('Compilation from Array', (t) => { const expected = 0; - const actual = output.status; + const actual = MakeNSIS.compileSync(null, { + wine: true, + preExecute: defaultScriptArray, + }).status; t.is(actual, expected); - }) - .catch(); }); -test('Compilation from String [async]', t => { - return Promise.resolve(MakeNSIS.compile(null, { wine: true, preExecute: defaultScriptString })) - .then(output => { +test('Compilation from String', (t) => { const expected = 0; - const actual = output.status; + const actual = MakeNSIS.compileSync(null, { + wine: true, + preExecute: defaultScriptString, + }).status; t.is(actual, expected); - }) - .catch(); }); -test('Compilation with warning', t => { - const scriptWithWarning = defaultScriptArray.concat(['!warning']); +test('Compilation from File [async]', async (t) => { + try { + const { status } = await MakeNSIS.compile(scriptFile.minimal, { + wine: true, + define: { + NULL_DEVICE: nullDevice, + }, + }); + + const expected = 0; + const actual = status; + + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } +}); - const expected = 0; - const actual = MakeNSIS.compileSync(null, { wine: true, preExecute: scriptWithWarning }).status; +test('Compilation from Array [async]', (t) => { + return Promise.resolve( + MakeNSIS.compile(null, { wine: true, preExecute: defaultScriptArray }) + ) + .then((output) => { + const expected = 0; + const actual = output.status; - t.is(actual, expected); + t.is(actual, expected); + }) + .catch(); }); -test('Compilation with warning as JSON', t => { - const expected = 1; - const scriptWithWarning = defaultScriptArray.concat(['!warning']); - const actual = MakeNSIS.compileSync(null, { wine: true, preExecute: scriptWithWarning, json: true }).warnings; +test('Compilation from String [async]', (t) => { + return Promise.resolve( + MakeNSIS.compile(null, { wine: true, preExecute: defaultScriptString }) + ) + .then((output) => { + const expected = 0; + const actual = output.status; - t.is(actual, expected); + t.is(actual, expected); + }) + .catch(); }); -test('Compilation with warning [async]', t => { - const scriptWithWarning = defaultScriptArray.concat(['!warning']); +test('Compilation with warning', (t) => { + const scriptWithWarning = defaultScriptArray.concat(['!warning']); - return Promise.resolve(MakeNSIS.compile(null, { wine: true, preExecute: scriptWithWarning })) - .then( output => { const expected = 0; - const actual = output.status; + const actual = MakeNSIS.compileSync(null, { + wine: true, + preExecute: scriptWithWarning, + }).status; t.is(actual, expected); - }) - .catch(); }); -test('Compilation with warning as JSON [async]', t => { - const scriptWithWarning = defaultScriptArray.concat(['!warning']); - - return Promise.resolve(MakeNSIS.compile(null, { wine: true, preExecute: scriptWithWarning, json: true })) - .then( output => { +test('Compilation with warning as JSON', (t) => { const expected = 1; - const actual = output.warnings; + const scriptWithWarning = defaultScriptArray.concat(['!warning']); + const actual = MakeNSIS.compileSync(null, { + wine: true, + preExecute: scriptWithWarning, + json: true, + }).warnings; t.is(actual, expected); - }) - .catch(); }); -test('Compilation with error', t => { - const scriptWithError = defaultScriptArray.concat(['!error']); +test('Compilation with warning [async]', (t) => { + const scriptWithWarning = defaultScriptArray.concat(['!warning']); - const expected = 0; - const actual = MakeNSIS.compileSync(null, { wine: true, preExecute: scriptWithError }).status; + return Promise.resolve( + MakeNSIS.compile(null, { wine: true, preExecute: scriptWithWarning }) + ) + .then((output) => { + const expected = 0; + const actual = output.status; - t.not(actual, expected); + t.is(actual, expected); + }) + .catch(); }); -test('Compilation with error [async]', t => { - let scriptWithError = defaultScriptArray.concat(['!error']); +test('Compilation with warning as JSON [async]', (t) => { + const scriptWithWarning = defaultScriptArray.concat(['!warning']); - return Promise.resolve(MakeNSIS.compile(null, { wine: true, preExecute: scriptWithError })) - .then(output => { - const expected = 0; - const actual = output.status; - - t.not(actual, expected) - }) - .catch(output => { - const expected = 0; - const actual = output.status; + return Promise.resolve( + MakeNSIS.compile(null, { + wine: true, + preExecute: scriptWithWarning, + json: true, + }) + ) + .then((output) => { + const expected = 1; + const actual = output.warnings; - t.not(actual, expected) - }); + t.is(actual, expected); + }) + .catch(); }); -test('Compilation with raw arguments strings', t => { - const expected = ''; - const actual = MakeNSIS.compileSync(scriptFile.minimal, { wine: true, rawArguments: '-V0' }).stdout; +test('Compilation with error', (t) => { + const scriptWithError = defaultScriptArray.concat(['!error']); - t.is(actual, expected); + const expected = 0; + const actual = MakeNSIS.compileSync(null, { + wine: true, + preExecute: scriptWithError, + }).status; + + t.not(actual, expected); }); -test('Compilation with raw arguments strings [async]', async (t) => { - try { - const { status } = await MakeNSIS.compile(scriptFile.minimal, { wine: true, rawArguments: '-V0', define: { - 'NULL_DEVICE': nullDevice - }}); +test('Compilation with error [async]', (t) => { + let scriptWithError = defaultScriptArray.concat(['!error']); - const expected = 0; - const actual = status; + return Promise.resolve( + MakeNSIS.compile(null, { wine: true, preExecute: scriptWithError }) + ) + .then((output) => { + const expected = 0; + const actual = output.status; - t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } + t.not(actual, expected); + }) + .catch((output) => { + const expected = 0; + const actual = output.status; + + t.not(actual, expected); + }); }); -test('Compilation with raw arguments array', t => { - const expected = ''; - const actual = MakeNSIS.compileSync(scriptFile.minimal, { wine: true, rawArguments: ['-V0'] }).stdout; +test('Compilation with raw arguments strings', (t) => { + const expected = ''; + const actual = MakeNSIS.compileSync(scriptFile.minimal, { + wine: true, + rawArguments: '-V0', + }).stdout; - t.is(actual, expected); + t.is(actual, expected); }); -test('Compilation with raw arguments array [async]', async (t) => { - try { - const { status } = await MakeNSIS.compile(scriptFile.minimal, { wine: true, rawArguments: ['-V0'], define: { - 'NULL_DEVICE': nullDevice - }}); +test('Compilation with raw arguments strings [async]', async (t) => { + try { + const { status } = await MakeNSIS.compile(scriptFile.minimal, { + wine: true, + rawArguments: '-V0', + define: { + NULL_DEVICE: nullDevice, + }, + }); + + const expected = 0; + const actual = status; + + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } +}); - const expected = 0; - const actual = status; +test('Compilation with raw arguments array', (t) => { + const expected = ''; + const actual = MakeNSIS.compileSync(scriptFile.minimal, { + wine: true, + rawArguments: ['-V0'], + }).stdout; t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } }); -test('Compilation with raw arguments strings and warning', t => { - const expected = 1; - const actual = MakeNSIS.compileSync(scriptFile.warning, { wine: true, rawArguments: '-WX' }).status; - - t.is(actual, expected); +test('Compilation with raw arguments array [async]', async (t) => { + try { + const { status } = await MakeNSIS.compile(scriptFile.minimal, { + wine: true, + rawArguments: ['-V0'], + define: { + NULL_DEVICE: nullDevice, + }, + }); + + const expected = 0; + const actual = status; + + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); -test('Compilation with raw arguments strings and warning [async]', async (t) => { - try { - const { status } = await MakeNSIS.compile(scriptFile.warning, { wine: true, rawArguments: '-WX' }); - +test('Compilation with raw arguments strings and warning', (t) => { const expected = 1; - const actual = status; + const actual = MakeNSIS.compileSync(scriptFile.warning, { + wine: true, + rawArguments: '-WX', + }).status; t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } }); -test('Compilation with raw arguments array and warning', t => { - const expected = 1; - const actual = MakeNSIS.compileSync(scriptFile.warning, { wine: true, rawArguments: ['-WX'] }).status; - - t.is(actual, expected); +test('Compilation with raw arguments strings and warning [async]', async (t) => { + try { + const { status } = await MakeNSIS.compile(scriptFile.warning, { + wine: true, + rawArguments: '-WX', + }); + + const expected = 1; + const actual = status; + + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); -test('Compilation with raw arguments array and warning [async]', async (t) => { - try { - const { status } = await MakeNSIS.compile(scriptFile.warning, { wine: true, rawArguments: ['-WX'] }); - +test('Compilation with raw arguments array and warning', (t) => { const expected = 1; - const actual = status; + const actual = MakeNSIS.compileSync(scriptFile.warning, { + wine: true, + rawArguments: ['-WX'], + }).status; t.is(actual, expected); - } catch ({ stderr }) { - t.fail(stderr); - } }); -test('Strict compilation with warning', t => { - const scriptWithWarning = defaultScriptArray.concat(['!warning']); - - const expected = 0; - const actual = MakeNSIS.compileSync(null, { wine: true, preExecute: scriptWithWarning, strict: true}).status; - - t.not(actual, expected); +test('Compilation with raw arguments array and warning [async]', async (t) => { + try { + const { status } = await MakeNSIS.compile(scriptFile.warning, { + wine: true, + rawArguments: ['-WX'], + }); + + const expected = 1; + const actual = status; + + t.is(actual, expected); + } catch ({ stderr }) { + t.fail(stderr); + } }); -test('Strict compilation with warning [async]', t => { - const scriptWithWarning = defaultScriptArray.concat(['!warning']); - - return Promise.resolve(MakeNSIS.compile(null, { wine: true, preExecute: scriptWithWarning, strict: true})) - .then(output => { - const expected = 0; - const actual = output.status; +test('Strict compilation with warning', (t) => { + const scriptWithWarning = defaultScriptArray.concat(['!warning']); - t.not(actual, expected) - }) - .catch(output => { const expected = 0; - const actual = output.status; + const actual = MakeNSIS.compileSync(null, { + wine: true, + preExecute: scriptWithWarning, + strict: true, + }).status; - t.not(actual, expected) - }); + t.not(actual, expected); }); -test('Print ${NSISDIR}', t => { - const nsisDir = MakeNSIS.nsisDirSync({ wine: true}); - let nsisCfg = spawnSync('winepath', [nsisDir]).stdout.toString().trim(); - nsisCfg = join(nsisCfg, 'Include', 'MUI2.nsh'); +test('Strict compilation with warning [async]', (t) => { + const scriptWithWarning = defaultScriptArray.concat(['!warning']); - const expected = true; - const actual = existsSync(nsisCfg); + return Promise.resolve( + MakeNSIS.compile(null, { + wine: true, + preExecute: scriptWithWarning, + strict: true, + }) + ) + .then((output) => { + const expected = 0; + const actual = output.status; - t.is(actual, expected); + t.not(actual, expected); + }) + .catch((output) => { + const expected = 0; + const actual = output.status; + + t.not(actual, expected); + }); }); -test('Print ${NSISDIR} [async]', t => { - return Promise.resolve(MakeNSIS.nsisDir({ wine: true})) - .then(nsisDir => { +test('Print ${NSISDIR}', (t) => { + const nsisDir = MakeNSIS.nsisDirSync({ wine: true }); let nsisCfg = spawnSync('winepath', [nsisDir]).stdout.toString().trim(); nsisCfg = join(nsisCfg, 'Include', 'MUI2.nsh'); const expected = true; const actual = existsSync(nsisCfg); - t.is(actual, expected) - }).catch(error => { - t.fail(error); - }); + t.is(actual, expected); }); -test('Print ${NSISDIR} as JSON', t => { - const nsisDir = MakeNSIS.nsisDirSync({ wine: true, json: true}).nsisdir; - let nsisCfg = spawnSync('winepath', [nsisDir]).stdout.toString().trim(); - nsisCfg = join(nsisCfg, 'Include', 'MUI2.nsh'); +test('Print ${NSISDIR} [async]', (t) => { + return Promise.resolve(MakeNSIS.nsisDir({ wine: true })) + .then((nsisDir) => { + let nsisCfg = spawnSync('winepath', [nsisDir]) + .stdout.toString() + .trim(); + nsisCfg = join(nsisCfg, 'Include', 'MUI2.nsh'); - const expected = true; - const actual = existsSync(nsisCfg); + const expected = true; + const actual = existsSync(nsisCfg); - t.is(actual, expected); + t.is(actual, expected); + }) + .catch((error) => { + t.fail(error); + }); }); -test('Print ${NSISDIR} as JSON [async]', t => { - return Promise.resolve(MakeNSIS.nsisDir({ wine: true, json: true})) - .then(nsisDir => { - let nsisCfg = spawnSync('winepath', [nsisDir.nsisdir]).stdout.toString().trim(); +test('Print ${NSISDIR} as JSON', (t) => { + const nsisDir = MakeNSIS.nsisDirSync({ wine: true, json: true }).nsisdir; + let nsisCfg = spawnSync('winepath', [nsisDir]).stdout.toString().trim(); nsisCfg = join(nsisCfg, 'Include', 'MUI2.nsh'); const expected = true; const actual = existsSync(nsisCfg); - t.is(actual, expected) - }).catch(error => { - t.fail(error); - }); + t.is(actual, expected); +}); + +test('Print ${NSISDIR} as JSON [async]', (t) => { + return Promise.resolve(MakeNSIS.nsisDir({ wine: true, json: true })) + .then((nsisDir) => { + let nsisCfg = spawnSync('winepath', [nsisDir.nsisdir]) + .stdout.toString() + .trim(); + nsisCfg = join(nsisCfg, 'Include', 'MUI2.nsh'); + + const expected = true; + const actual = existsSync(nsisCfg); + + t.is(actual, expected); + }) + .catch((error) => { + t.fail(error); + }); });