JezK
Edit File: index.js
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = exports.autoRun = void 0; exports.main = main; function _regenerator() { var data = _interopRequireDefault(require("@babel/runtime/regenerator")); _regenerator = function _regenerator() { return data; }; return data; } function _defineProperty2() { var data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); _defineProperty2 = function _defineProperty2() { return data; }; return data; } function _toConsumableArray2() { var data = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); _toConsumableArray2 = function _toConsumableArray2() { return data; }; return data; } function _asyncToGenerator2() { var data = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); _asyncToGenerator2 = function _asyncToGenerator2() { return data; }; return data; } function _http() { var data = _interopRequireDefault(require("http")); _http = function _http() { return data; }; return data; } function _net() { var data = _interopRequireDefault(require("net")); _net = function _net() { return data; }; return data; } function _path() { var data = _interopRequireDefault(require("path")); _path = function _path() { return data; }; return data; } function _fs() { var data = _interopRequireDefault(require("fs")); _fs = function _fs() { return data; }; return data; } function _invariant() { var data = _interopRequireDefault(require("invariant")); _invariant = function _invariant() { return data; }; return data; } function _properLockfile() { var data = _interopRequireDefault(require("proper-lockfile")); _properLockfile = function _properLockfile() { return data; }; return data; } function _loudRejection() { var data = _interopRequireDefault(require("loud-rejection")); _loudRejection = function _loudRejection() { return data; }; return data; } function _death() { var data = _interopRequireDefault(require("death")); _death = function _death() { return data; }; return data; } function _semver() { var data = _interopRequireDefault(require("semver")); _semver = function _semver() { return data; }; return data; } function _index() { var data = require("../reporters/index.js"); _index = function _index() { return data; }; return data; } function _index2() { var data = require("../registries/index.js"); _index2 = function _index2() { return data; }; return data; } function _index3() { var data = _interopRequireDefault(require("./commands/index.js")); _index3 = function _index3() { return data; }; return data; } function constants() { var data = _interopRequireWildcard(require("../constants.js")); constants = function constants() { return data; }; return data; } function network() { var data = _interopRequireWildcard(require("../util/network.js")); network = function network() { return data; }; return data; } function _errors() { var data = require("../errors.js"); _errors = function _errors() { return data; }; return data; } function _config() { var data = _interopRequireDefault(require("../config.js")); _config = function _config() { return data; }; return data; } function _rc() { var data = require("../rc.js"); _rc = function _rc() { return data; }; return data; } function _child() { var data = require("../util/child.js"); _child = function _child() { return data; }; return data; } function _yarnVersion() { var data = require("../util/yarn-version.js"); _yarnVersion = function _yarnVersion() { return data; }; return data; } function _signalHandler() { var data = _interopRequireDefault(require("../util/signal-handler.js")); _signalHandler = function _signalHandler() { return data; }; return data; } function _conversion() { var data = require("../util/conversion.js"); _conversion = function _conversion() { return data; }; return data; } function _errors2() { var data = require("../errors"); _errors2 = function _errors2() { return data; }; return data; } function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2()["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } var _require = require('commander'), Command = _require.Command; var commander = new Command(); process.stdout.prependListener('error', function (err) { // swallow err only if downstream consumer process closed pipe early if (err.code === 'EPIPE' || err.code === 'ERR_STREAM_DESTROYED') { return; } throw err; }); function findProjectRoot(base) { var prev = null; var dir = base; do { if (_fs()["default"].existsSync(_path()["default"].join(dir, constants().NODE_PACKAGE_JSON))) { return dir; } prev = dir; dir = _path()["default"].dirname(dir); } while (dir !== prev); return base; } function main(_x) { return _main.apply(this, arguments); } function _main() { _main = (0, _asyncToGenerator2()["default"])( /*#__PURE__*/_regenerator()["default"].mark(function _callee(_ref) { var startArgs, args, endArgs, collect, firstNonFlagIndex, preCommandArgs, commandName, isKnownCommand, isHelp, helpInPre, helpInArgs, setHelpMode, command, warnAboutRunDashDash, PROXY_COMMANDS, preservedArgs, commanderOpts, Reporter, reporter, exit, config, outputWrapperEnabled, shouldWrapOutput, run, runEventuallyWithFile, runEventuallyWithNetwork, onUnexpectedError, writeErrorReport, cwd, folderOptionKeys, resolvedFolderOptions; return _regenerator()["default"].wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: writeErrorReport = function _writeErrorReport(log) { var errorReportLoc = config.enableMetaFolder ? _path()["default"].join(config.cwd, constants().META_FOLDER, 'yarn-error.log') : _path()["default"].join(config.cwd, 'yarn-error.log'); try { _fs()["default"].writeFileSync(errorReportLoc, log.join('\n\n') + '\n'); } catch (err) { reporter.error(reporter.lang('fileWriteError', errorReportLoc, err.message)); return undefined; } return errorReportLoc; }; onUnexpectedError = function _onUnexpectedError(err) { function indent(str) { return '\n ' + str.trim().split('\n').join('\n '); } var log = []; log.push("Arguments: ".concat(indent(process.argv.join(' ')))); log.push("PATH: ".concat(indent(process.env.PATH || 'undefined'))); log.push("Yarn version: ".concat(indent(_yarnVersion().version))); log.push("Node version: ".concat(indent(process.versions.node))); log.push("Platform: ".concat(indent(process.platform + ' ' + process.arch))); log.push("Trace: ".concat(indent(err.stack))); // add manifests var _iterator3 = _createForOfIteratorHelper(_index2().registryNames), _step3; try { for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { var registryName = _step3.value; var possibleLoc = _path()["default"].join(config.cwd, _index2().registries[registryName].filename); var manifest = _fs()["default"].existsSync(possibleLoc) ? _fs()["default"].readFileSync(possibleLoc, 'utf8') : 'No manifest'; log.push("".concat(registryName, " manifest: ").concat(indent(manifest))); } // lockfile } catch (err) { _iterator3.e(err); } finally { _iterator3.f(); } var lockLoc = _path()["default"].join(config.lockfileFolder || config.cwd, // lockfileFolder might not be set at this point constants().LOCKFILE_FILENAME); var lockfile = _fs()["default"].existsSync(lockLoc) ? _fs()["default"].readFileSync(lockLoc, 'utf8') : 'No lockfile'; log.push("Lockfile: ".concat(indent(lockfile))); var errorReportLoc = writeErrorReport(log); reporter.error(reporter.lang('unexpectedError', err.message)); if (errorReportLoc) { reporter.info(reporter.lang('bugReport', errorReportLoc)); } }; startArgs = _ref.startArgs, args = _ref.args, endArgs = _ref.endArgs; collect = function collect(val, acc) { acc.push(val); return acc; }; (0, _loudRejection()["default"])(); (0, _signalHandler()["default"])(); // if -v/--version is the first argument, then always exit after returning the version if (!(args[0] === '-v' || args[0] === '--version')) { _context.next = 10; break; } console.log(_yarnVersion().version.trim()); process.exitCode = 0; return _context.abrupt("return"); case 10: // set global options commander.name('yarnpkg'); commander.version(_yarnVersion().version, '-v, --version'); commander.usage('[command] [flags]'); commander.option('--no-default-rc', 'prevent Yarn from automatically detecting yarnrc and npmrc files'); commander.option('--use-yarnrc <path>', 'specifies a yarnrc file that Yarn should use (.yarnrc only, not .npmrc)', collect, []); commander.option('--verbose', 'output verbose messages on internal operations'); commander.option('--offline', 'trigger an error if any required dependencies are not available in local cache'); commander.option('--prefer-offline', 'use network only if dependencies are not available in local cache'); commander.option('--enable-pnp, --pnp', "enable the Plug'n'Play installation"); commander.option('--disable-pnp', "disable the Plug'n'Play installation"); commander.option('--strict-semver'); commander.option('--json', 'format Yarn log messages as lines of JSON (see jsonlines.org)'); commander.option('--ignore-scripts', "don't run lifecycle scripts"); commander.option('--har', 'save HAR output of network traffic'); commander.option('--ignore-platform', 'ignore platform checks'); commander.option('--ignore-engines', 'ignore engines check'); commander.option('--ignore-optional', 'ignore optional dependencies'); commander.option('--force', 'install and build packages even if they were built before, overwrite lockfile'); commander.option('--skip-integrity-check', 'run install without checking if node_modules is installed'); commander.option('--check-files', 'install will verify file tree of packages for consistency'); commander.option('--no-bin-links', "don't generate bin links when setting up packages"); commander.option('--flat', 'only allow one version of a package'); commander.option('--prod, --production [prod]', '', _conversion().boolify); commander.option('--no-lockfile', "don't read or generate a lockfile"); commander.option('--pure-lockfile', "don't generate a lockfile"); commander.option('--frozen-lockfile', "don't generate a lockfile and fail if an update is needed"); commander.option('--update-checksums', 'update package checksums from current repository'); commander.option('--link-duplicates', 'create hardlinks to the repeated modules in node_modules'); commander.option('--link-folder <path>', 'specify a custom folder to store global links'); commander.option('--global-folder <path>', 'specify a custom folder to store global packages'); commander.option('--modules-folder <path>', 'rather than installing modules into the node_modules folder relative to the cwd, output them here'); commander.option('--preferred-cache-folder <path>', 'specify a custom folder to store the yarn cache if possible'); commander.option('--cache-folder <path>', 'specify a custom folder that must be used to store the yarn cache'); commander.option('--mutex <type>[:specifier]', 'use a mutex to ensure only one yarn instance is executing'); commander.option('--emoji [bool]', 'enable emoji in output', _conversion().boolify, process.platform === 'darwin' || process.env.TERM_PROGRAM === 'Hyper' || process.env.TERM_PROGRAM === 'HyperTerm' || process.env.TERM_PROGRAM === 'Terminus'); commander.option('-s, --silent', 'skip Yarn console logs, other types of logs (script output) will be printed'); commander.option('--cwd <cwd>', 'working directory to use', process.cwd()); commander.option('--proxy <host>', ''); commander.option('--https-proxy <host>', ''); commander.option('--registry <url>', 'override configuration registry'); commander.option('--no-progress', 'disable progress bar'); commander.option('--network-concurrency <number>', 'maximum number of concurrent network requests', parseInt); commander.option('--network-timeout <milliseconds>', 'TCP timeout for network requests', parseInt); commander.option('--non-interactive', 'do not show interactive prompts'); commander.option('--scripts-prepend-node-path [bool]', 'prepend the node executable dir to the PATH in scripts', _conversion().boolify); commander.option('--no-node-version-check', 'do not warn when using a potentially unsupported Node version'); commander.option('--focus', 'Focus on a single workspace by installing remote copies of its sibling workspaces.'); commander.option('--otp <otpcode>', 'one-time password for two factor authentication'); // get command name firstNonFlagIndex = args.findIndex(function (arg, idx, arr) { var isOption = arg.startsWith('-'); var prev = idx > 0 && arr[idx - 1]; var prevOption = prev && prev.startsWith('-') && commander._findOption(prev); var boundToPrevOption = prevOption && (prevOption.optional || prevOption.required); return !isOption && !boundToPrevOption; }); commandName = ''; if (firstNonFlagIndex > -1) { preCommandArgs = args.slice(0, firstNonFlagIndex); commandName = args[firstNonFlagIndex]; args = args.slice(firstNonFlagIndex + 1); } else { preCommandArgs = args; args = []; } isKnownCommand = Object.prototype.hasOwnProperty.call(_index3()["default"], commandName); isHelp = function isHelp(arg) { return arg === '--help' || arg === '-h'; }; helpInPre = preCommandArgs.findIndex(isHelp); helpInArgs = args.findIndex(isHelp); setHelpMode = function setHelpMode() { if (isKnownCommand) { args.unshift(commandName); } commandName = 'help'; isKnownCommand = true; }; if (helpInPre > -1) { preCommandArgs.splice(helpInPre); setHelpMode(); } else if (isKnownCommand && helpInArgs === 0) { args.splice(helpInArgs); setHelpMode(); } if (!commandName) { commandName = 'install'; isKnownCommand = true; } if (commandName === 'set' && args[0] === 'version') { commandName = 'policies'; args.splice(0, 1, 'set-version'); isKnownCommand = true; } if (!isKnownCommand) { // if command is not recognized, then set default to `run` args.unshift(commandName); commandName = 'run'; } command = _index3()["default"][commandName]; warnAboutRunDashDash = false; // we are using "yarn <script> -abc", "yarn run <script> -abc", or "yarn node -abc", we want -abc // to be script options, not yarn options // PROXY_COMMANDS is a map of command name to the number of preservedArgs PROXY_COMMANDS = { run: 1, // yarn run {command} create: 1, // yarn create {project} node: 0, // yarn node workspaces: 1, // yarn workspaces {command} workspace: 2 // yarn workspace {package} {command} }; if (PROXY_COMMANDS.hasOwnProperty(commandName)) { if (endArgs.length === 0) { // $FlowFixMe doesn't like that PROXY_COMMANDS doesn't have keys for all commands. preservedArgs = PROXY_COMMANDS[commandName]; // If the --into option immediately follows the command (or the script name in the "run/create" // case), we parse them as regular options so that we can cd into them if (args[preservedArgs] === "--into") { preservedArgs += 2; } endArgs = ['--'].concat((0, _toConsumableArray2()["default"])(args.splice(preservedArgs))); } else { warnAboutRunDashDash = true; } } args = [].concat((0, _toConsumableArray2()["default"])(preCommandArgs), (0, _toConsumableArray2()["default"])(args)); command.setFlags(commander); commander.parse([].concat((0, _toConsumableArray2()["default"])(startArgs), [ // we use this for https://github.com/tj/commander.js/issues/346, otherwise // it will strip some args that match with any options 'this-arg-will-get-stripped-later'], (0, _toConsumableArray2()["default"])((0, _rc().getRcArgs)(commandName, args)), (0, _toConsumableArray2()["default"])(args))); commander.args = commander.args.concat(endArgs.slice(1)); // we strip cmd console.assert(commander.args.length >= 1); console.assert(commander.args[0] === 'this-arg-will-get-stripped-later'); commander.args.shift(); commanderOpts = commander.opts(); // Reporter = commanderOpts.json ? _index().JSONReporter : _index().ConsoleReporter; reporter = new Reporter({ emoji: process.stdout.isTTY && commanderOpts.emoji, verbose: commanderOpts.verbose, noProgress: !commanderOpts.progress, isSilent: (0, _conversion().boolifyWithDefault)(process.env.YARN_SILENT, false) || commanderOpts.silent, nonInteractive: commanderOpts.nonInteractive }); exit = function exit(exitCode) { process.exitCode = exitCode || 0; reporter.close(); }; reporter.initPeakMemoryCounter(); config = new (_config()["default"])(reporter); outputWrapperEnabled = (0, _conversion().boolifyWithDefault)(process.env.YARN_WRAP_OUTPUT, true); shouldWrapOutput = outputWrapperEnabled && !commanderOpts.json && command.hasWrapper(commander, commander.args) && !(commandName === 'init' && commanderOpts["2"]); if (shouldWrapOutput) { reporter.header(commandName, { name: 'yarn', version: _yarnVersion().version }); } if (commanderOpts.nodeVersionCheck && !_semver()["default"].satisfies(process.versions.node, constants().SUPPORTED_NODE_VERSIONS)) { reporter.warn(reporter.lang('unsupportedNodeVersion', process.versions.node, constants().SUPPORTED_NODE_VERSIONS)); } if (!(command.noArguments && commander.args.length > 0)) { _context.next = 96; break; } reporter.error(reporter.lang('noArguments')); reporter.info(command.getDocsInfo); exit(1); return _context.abrupt("return"); case 96: // if (commanderOpts.yes) { reporter.warn(reporter.lang('yesWarning')); } // if (!commanderOpts.offline && network().isOffline()) { reporter.warn(reporter.lang('networkWarning')); } // run = function run() { (0, _invariant()["default"])(command, 'missing command'); if (warnAboutRunDashDash) { reporter.warn(reporter.lang('dashDashDeprecation')); } return command.run(config, reporter, commander, commanderOpts, commander.args).then(function (exitCode) { if (shouldWrapOutput) { reporter.footer(false); } return exitCode; }); }; // runEventuallyWithFile = function runEventuallyWithFile(mutexFilename, isFirstTime) { return new Promise(function (resolve) { var lockFilename = mutexFilename || _path()["default"].join(config.cwd, constants().SINGLE_INSTANCE_FILENAME); _properLockfile()["default"].lock(lockFilename, { realpath: false }).then(function (release) { (0, _death()["default"])(function () { process.exitCode = 1; }); resolve(run().then(function () { return new Promise(function (resolve) { return release(resolve); }); })); })["catch"](function (err) { if (isFirstTime) { reporter.warn(reporter.lang('waitingInstance')); } setTimeout(function () { resolve(runEventuallyWithFile(mutexFilename, false)); }, 200); // do not starve the CPU }); }); }; runEventuallyWithNetwork = function runEventuallyWithNetwork(mutexPort) { return new Promise(function (resolve, reject) { var connectionOptions = { port: +mutexPort || constants().SINGLE_INSTANCE_PORT, host: 'localhost' }; function startServer() { var clients = new Set(); var server = _http()["default"].createServer(manager); // The server must not prevent us from exiting server.unref(); // No socket must timeout, so that they aren't closed before we exit server.timeout = 0; // If we fail to setup the server, we ask the existing one for its name server.on('error', function () { reportServerName(); }); // If we succeed, keep track of all the connected sockets to close them later server.on('connection', function (socket) { clients.add(socket); socket.on('close', function () { clients["delete"](socket); }); }); server.listen(connectionOptions, function () { // Don't forget to kill the sockets if we're being killed via signals (0, _death()["default"])(killSockets); // Also kill the sockets if we finish, whether it's a success or a failure run().then(function (res) { killSockets(); resolve(res); }, function (err) { killSockets(); reject(err); }); }); function manager(request, response) { response.writeHead(200); response.end(JSON.stringify({ cwd: config.cwd, pid: process.pid })); } function killSockets() { try { server.close(); } catch (err) { // best effort } var _iterator = _createForOfIteratorHelper(clients), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var socket = _step.value; try { socket.destroy(); } catch (err) { // best effort } } // If the process hasn't exited in the next 5s, it has stalled and we abort } catch (err) { _iterator.e(err); } finally { _iterator.f(); } var timeout = setTimeout(function () { console.error('Process stalled'); if (process._getActiveHandles) { console.error('Active handles:'); // $FlowFixMe: getActiveHandles is undocumented, but it exists var _iterator2 = _createForOfIteratorHelper(process._getActiveHandles()), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var handle = _step2.value; console.error(" - ".concat(handle.constructor.name)); } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } } // eslint-disable-next-line no-process-exit process.exit(1); }, 5000); // This timeout must not prevent us from exiting // $FlowFixMe: Node's setTimeout returns a Timeout, not a Number timeout.unref(); } } function reportServerName() { var request = _http()["default"].get(connectionOptions, function (response) { var buffers = []; response.on('data', function (buffer) { buffers.push(buffer); }); response.on('end', function () { try { var _JSON$parse = JSON.parse(Buffer.concat(buffers).toString()), _cwd = _JSON$parse.cwd, pid = _JSON$parse.pid; reporter.warn(reporter.lang('waitingNamedInstance', pid, _cwd)); } catch (error) { reporter.verbose(error); reject(new Error(reporter.lang('mutexPortBusy', connectionOptions.port))); return; } waitForTheNetwork(); }); response.on('error', function () { startServer(); }); }); request.on('error', function () { startServer(); }); } function waitForTheNetwork() { var socket = _net()["default"].createConnection(connectionOptions); socket.on('error', function () { // catch & ignore, the retry is handled in 'close' }); socket.on('close', function () { startServer(); }); } startServer(); }); }; cwd = command.shouldRunInCurrentCwd ? commanderOpts.cwd : findProjectRoot(commanderOpts.cwd); folderOptionKeys = ['linkFolder', 'globalFolder', 'preferredCacheFolder', 'cacheFolder', 'modulesFolder']; // Resolve all folder options relative to cwd resolvedFolderOptions = {}; folderOptionKeys.forEach(function (folderOptionKey) { var folderOption = commanderOpts[folderOptionKey]; var resolvedFolderOption = folderOption ? _path()["default"].resolve(commanderOpts.cwd, folderOption) : folderOption; resolvedFolderOptions[folderOptionKey] = resolvedFolderOption; }); _context.next = 107; return config.init(_objectSpread(_objectSpread({ cwd: cwd, commandName: commandName }, resolvedFolderOptions), {}, { enablePnp: commanderOpts.pnp, disablePnp: commanderOpts.disablePnp, enableDefaultRc: commanderOpts.defaultRc, extraneousYarnrcFiles: commanderOpts.useYarnrc, binLinks: commanderOpts.binLinks, preferOffline: commanderOpts.preferOffline, captureHar: commanderOpts.har, ignorePlatform: commanderOpts.ignorePlatform, ignoreEngines: commanderOpts.ignoreEngines, ignoreScripts: commanderOpts.ignoreScripts, offline: commanderOpts.preferOffline || commanderOpts.offline, looseSemver: !commanderOpts.strictSemver, production: commanderOpts.production, httpProxy: commanderOpts.proxy, httpsProxy: commanderOpts.httpsProxy, registry: commanderOpts.registry, networkConcurrency: commanderOpts.networkConcurrency, networkTimeout: commanderOpts.networkTimeout, nonInteractive: commanderOpts.nonInteractive, updateChecksums: commanderOpts.updateChecksums, focus: commanderOpts.focus, otp: commanderOpts.otp })).then(function () { // lockfile check must happen after config.init sets lockfileFolder if (command.requireLockfile && !_fs()["default"].existsSync(_path()["default"].join(config.lockfileFolder, constants().LOCKFILE_FILENAME))) { throw new (_errors().MessageError)(reporter.lang('noRequiredLockfile')); } // option "no-progress" stored in yarn config var noProgressConfig = config.registries.yarn.getOption('no-progress'); if (noProgressConfig) { reporter.disableProgress(); } // verbose logs outputs process.uptime() with this line we can sync uptime to absolute time on the computer reporter.verbose("current time: ".concat(new Date().toISOString())); var mutex = commanderOpts.mutex; if (mutex && typeof mutex === 'string') { var separatorLoc = mutex.indexOf(':'); var mutexType; var mutexSpecifier; if (separatorLoc === -1) { mutexType = mutex; mutexSpecifier = undefined; } else { mutexType = mutex.substring(0, separatorLoc); mutexSpecifier = mutex.substring(separatorLoc + 1); } if (mutexType === 'file') { return runEventuallyWithFile(mutexSpecifier, true).then(exit); } else if (mutexType === 'network') { return runEventuallyWithNetwork(mutexSpecifier).then(exit); } else { throw new (_errors().MessageError)("Unknown single instance type ".concat(mutexType)); } } else { return run().then(exit); } })["catch"](function (err) { reporter.verbose(err.stack); if (err instanceof _errors2().ProcessTermError && reporter.isSilent) { return exit(err.EXIT_CODE || 1); } if (err instanceof _errors().MessageError) { reporter.error(err.message); } else { onUnexpectedError(err); } if (command.getDocsInfo) { reporter.info(command.getDocsInfo); } if (err instanceof _errors2().ProcessTermError) { return exit(err.EXIT_CODE || 1); } return exit(1); }); case 107: case "end": return _context.stop(); } }, _callee); })); return _main.apply(this, arguments); } function start() { return _start.apply(this, arguments); } // When this module is compiled via Webpack, its child // count will be 0 since it is a single-file bundle. function _start() { _start = (0, _asyncToGenerator2()["default"])( /*#__PURE__*/_regenerator()["default"].mark(function _callee2() { var rc, yarnPath, argv, opts, exitCode, doubleDashIndex, startArgs, _args2, endArgs; return _regenerator()["default"].wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: rc = (0, _rc().getRcConfigForCwd)(process.cwd(), process.argv.slice(2)); yarnPath = rc['yarn-path'] || rc['yarnPath']; if (!(yarnPath && !(0, _conversion().boolifyWithDefault)(process.env.YARN_IGNORE_PATH, false))) { _context2.next = 34; break; } argv = process.argv.slice(2); opts = { stdio: 'inherit', env: Object.assign({}, process.env, { YARN_IGNORE_PATH: 1 }) }; exitCode = 0; process.on("SIGINT", function () { // We don't want SIGINT to kill our process; we want it to kill the // innermost process, whose end will cause our own to exit. }); (0, _signalHandler()["default"])(); _context2.prev = 8; if (!/\.[cm]?js$/.test(yarnPath)) { _context2.next = 15; break; } _context2.next = 12; return (0, _child().spawnp)(process.execPath, [yarnPath].concat((0, _toConsumableArray2()["default"])(argv)), opts); case 12: exitCode = _context2.sent; _context2.next = 18; break; case 15: _context2.next = 17; return (0, _child().spawnp)(yarnPath, argv, opts); case 17: exitCode = _context2.sent; case 18: _context2.next = 31; break; case 20: _context2.prev = 20; _context2.t0 = _context2["catch"](8); _context2.prev = 22; _context2.next = 25; return (0, _child().forkp)(yarnPath, argv, opts); case 25: exitCode = _context2.sent; _context2.next = 31; break; case 28: _context2.prev = 28; _context2.t1 = _context2["catch"](22); throw _context2.t0; case 31: process.exitCode = exitCode; _context2.next = 40; break; case 34: // ignore all arguments after a -- doubleDashIndex = process.argv.findIndex(function (element) { return element === '--'; }); startArgs = process.argv.slice(0, 2); _args2 = process.argv.slice(2, doubleDashIndex === -1 ? process.argv.length : doubleDashIndex); endArgs = doubleDashIndex === -1 ? [] : process.argv.slice(doubleDashIndex); _context2.next = 40; return main({ startArgs: startArgs, args: _args2, endArgs: endArgs }); case 40: case "end": return _context2.stop(); } }, _callee2, null, [[8, 20], [22, 28]]); })); return _start.apply(this, arguments); } var autoRun = module.children.length === 0; exports.autoRun = autoRun; if (require.main === module) { start()["catch"](function (error) { console.error(error.stack || error.message || error); process.exitCode = 1; }); } var _default = start; exports["default"] = _default; //# sourceMappingURL=index.js.map