JezK
Edit File: portable-script.js.map
{"version":3,"file":"portable-script.js","names":["path","require","makePortableProxyScriptUnix","source","destination","options","environment","extraEnvironment","Array","from","entries","map","key","value","join","prependedArguments","prependArguments","arg","appendedArguments","appendArguments","filePath","proxyBasename","basename","sourcePath","isAbsolute","fs","mkdirp","process","platform","writeFile","chmod","makePortableProxyScript"],"sourceRoot":"../../src","sources":["util/portable-script.js"],"sourcesContent":["/* @flow */\n\nimport * as fs from './fs.js';\n\nconst path = require('path');\n\nexport type PortableProxyOptions = {|\n proxyBasename?: string,\n extraEnvironment?: Map<string, string>,\n prependArguments?: Array<string>,\n appendArguments?: Array<string>,\n pnpPackageName?: string,\n|};\n\nasync function makePortableProxyScriptUnix(\n source: string,\n destination: string,\n options: PortableProxyOptions,\n): Promise<void> {\n const environment = options.extraEnvironment\n ? Array.from(options.extraEnvironment.entries()).map(([key, value]) => `${key}=\"${value}\"`).join(' ') + ' '\n : '';\n\n const prependedArguments = options.prependArguments\n ? ' ' + options.prependArguments.map(arg => `\"${arg}\"`).join(' ')\n : '';\n const appendedArguments = options.appendArguments\n ? ' ' + options.appendArguments.map(arg => `\"${arg}\"`).join(' ')\n : '';\n\n const filePath = `${destination}/${options.proxyBasename || path.basename(source)}`;\n\n // Unless impossible we want to preserve any symlinks used to call us when forwarding the call to the binary (so we\n // cannot use realpath or transform relative paths into absolute ones), but we also need to tell the sh interpreter\n // that the symlink should be resolved relative to the script directory (hence dirname \"$0\" at runtime).\n const sourcePath = path.isAbsolute(source) ? source : `$(dirname \"$0\")/../${source}`;\n\n await fs.mkdirp(destination);\n\n if (process.platform === 'win32') {\n await fs.writeFile(\n filePath + '.cmd',\n `@${environment}\"${sourcePath}\" ${prependedArguments} ${appendedArguments} %*\\r\\n`,\n );\n } else {\n await fs.writeFile(\n filePath,\n `#!/bin/sh\\n\\n${environment}exec \"${sourcePath}\"${prependedArguments} \"$@\"${appendedArguments}\\n`,\n );\n await fs.chmod(filePath, 0o755);\n }\n}\n\nexport function makePortableProxyScript(\n source: string,\n destination: string,\n // $FlowFixMe Flow doesn't support exact types with empty default values\n options: PortableProxyOptions = {},\n): Promise<void> {\n return makePortableProxyScriptUnix(source, destination, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA8B;AAAA;AAE9B,IAAMA,IAAI,GAAGC,OAAO,CAAC,MAAM,CAAC;AAAC,SAUdC,2BAA2B;EAAA;AAAA;AAAA;EAAA,iHAA1C,iBACEC,MAAc,EACdC,WAAmB,EACnBC,OAA6B;IAAA;IAAA;MAAA;QAAA;UAEvBC,WAAW,GAAGD,OAAO,CAACE,gBAAgB,GACxCC,KAAK,CAACC,IAAI,CAACJ,OAAO,CAACE,gBAAgB,CAACG,OAAO,EAAE,CAAC,CAACC,GAAG,CAAC;YAAA;cAAEC,GAAG;cAAEC,KAAK;YAAA,iBAASD,GAAG,gBAAKC,KAAK;UAAA,CAAG,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,GACzG,EAAE;UAEAC,kBAAkB,GAAGV,OAAO,CAACW,gBAAgB,GAC/C,GAAG,GAAGX,OAAO,CAACW,gBAAgB,CAACL,GAAG,CAAC,UAAAM,GAAG;YAAA,mBAAQA,GAAG;UAAA,CAAG,CAAC,CAACH,IAAI,CAAC,GAAG,CAAC,GAC/D,EAAE;UACAI,iBAAiB,GAAGb,OAAO,CAACc,eAAe,GAC7C,GAAG,GAAGd,OAAO,CAACc,eAAe,CAACR,GAAG,CAAC,UAAAM,GAAG;YAAA,mBAAQA,GAAG;UAAA,CAAG,CAAC,CAACH,IAAI,CAAC,GAAG,CAAC,GAC9D,EAAE;UAEAM,QAAQ,aAAMhB,WAAW,cAAIC,OAAO,CAACgB,aAAa,IAAIrB,IAAI,CAACsB,QAAQ,CAACnB,MAAM,CAAC,GAEjF;UACA;UACA;UACMoB,UAAU,GAAGvB,IAAI,CAACwB,UAAU,CAACrB,MAAM,C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