UNPKG

@keymanapp/kmc

Version:

Keyman Developer compiler command line tools

47 lines (45 loc) 2.31 kB
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="50a35a1a-7e85-5013-af6a-b19584c37390")}catch(e){}}(); import * as fs from 'fs'; import * as path from 'path'; import { defaultCompilerOptions } from '@keymanapp/developer-utils'; import { NodeCompilerCallbacks } from '../../util/NodeCompilerCallbacks.js'; import { WindowsPackageInstallerCompiler } from '@keymanapp/kmc-package'; import { exitProcess } from '../../util/sysexits.js'; ; export async function buildWindowsPackageInstaller(infile, _options, commander) { // TODO(lowpri): we probably should cleanup the options management here, move // translation of command line options to kmc-* options into a separate module const options = commander.optsWithGlobals(); const sources = { licenseFilename: options.license, msiFilename: options.msi, setupExeFilename: options.exe, startDisabled: options.startDisabled, startWithConfiguration: options.startWithConfiguration, appName: options.appName, titleImageFilename: options.titleImage }; const outfile = options.outFile; // Normalize case for the filename and expand the path; this avoids false // positive case mismatches on input filenames and glommed paths infile = fs.realpathSync.native(infile); const callbacks = new NodeCompilerCallbacks({ ...defaultCompilerOptions, ...options }); const compiler = new WindowsPackageInstallerCompiler(); if (!await compiler.init(callbacks, { ...options, sources })) { return await exitProcess(1); } const fileBaseName = outfile ?? infile; const outFileBase = path.basename(fileBaseName, path.extname(fileBaseName)); const outFileDir = path.dirname(fileBaseName); const outFileExe = path.join(outFileDir, outFileBase + '.exe'); const result = await compiler.run(infile, outFileExe); if (!result) { // errors will have been reported already return await exitProcess(1); } if (!await compiler.write(result.artifacts)) { return await exitProcess(1); } } //# sourceMappingURL=index.js.map //# debugId=50a35a1a-7e85-5013-af6a-b19584c37390