Son CV dans un terminal web en Javascript! https://terminal-cv.gregandev.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

207 lines
4.4 KiB

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Yarn = void 0;
function _commandExists() {
const data = _interopRequireDefault(require("command-exists"));
_commandExists = function () {
return data;
};
return data;
}
function _crossSpawn() {
const data = _interopRequireDefault(require("cross-spawn"));
_crossSpawn = function () {
return data;
};
return data;
}
function _child_process() {
const data = require("child_process");
_child_process = function () {
return data;
};
return data;
}
function _util() {
const data = require("util");
_util = function () {
return data;
};
return data;
}
function _logger() {
const data = _interopRequireDefault(require("@parcel/logger"));
_logger = function () {
return data;
};
return data;
}
function _split() {
const data = _interopRequireDefault(require("split2"));
_split = function () {
return data;
};
return data;
}
var _JSONParseStream = _interopRequireDefault(require("./JSONParseStream"));
var _promiseFromProcess = _interopRequireDefault(require("./promiseFromProcess"));
function _core() {
const data = require("@parcel/core");
_core = function () {
return data;
};
return data;
}
var _utils = require("./utils");
var _package = _interopRequireDefault(require("../package.json"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// $FlowFixMe
const YARN_CMD = 'yarn';
const exec = (0, _util().promisify)(_child_process().exec);
let hasYarn;
let yarnVersion;
class Yarn {
static async exists() {
if (hasYarn != null) {
return hasYarn;
}
try {
hasYarn = Boolean(await (0, _commandExists().default)('yarn'));
} catch (err) {
hasYarn = false;
}
return hasYarn;
}
async install({
modules,
cwd,
saveDev = true
}) {
if (yarnVersion == null) {
let version = await exec('yarn --version');
yarnVersion = parseInt(version.stdout, 10);
}
let args = ['add', '--json'].concat(modules.map(_utils.npmSpecifierFromModuleRequest));
if (saveDev) {
args.push('-D');
if (yarnVersion < 2) {
args.push('-W');
}
} // When Parcel is run by Yarn (e.g. via package.json scripts), several environment variables are
// added. When parcel in turn calls Yarn again, these can cause Yarn to behave stragely, so we
// filter them out when installing packages.
let env = {};
for (let key in process.env) {
if (!key.startsWith('npm_') && key !== 'YARN_WRAP_OUTPUT' && key !== 'INIT_CWD' && key !== 'NODE_ENV') {
env[key] = process.env[key];
}
}
let installProcess = (0, _crossSpawn().default)(YARN_CMD, args, {
cwd,
env
});
installProcess.stdout // Invoking yarn with --json provides streaming, newline-delimited JSON output.
.pipe((0, _split().default)()).pipe(new _JSONParseStream.default()).on('error', e => {
_logger().default.error(e, '@parcel/package-manager');
}).on('data', message => {
switch (message.type) {
case 'step':
_logger().default.progress(prefix(`[${message.data.current}/${message.data.total}] ${message.data.message}`));
return;
case 'success':
case 'info':
_logger().default.info({
origin: '@parcel/package-manager',
message: prefix(message.data)
});
return;
default: // ignore
}
});
installProcess.stderr.pipe((0, _split().default)()).pipe(new _JSONParseStream.default()).on('error', e => {
_logger().default.error(e, '@parcel/package-manager');
}).on('data', message => {
switch (message.type) {
case 'warning':
_logger().default.warn({
origin: '@parcel/package-manager',
message: prefix(message.data)
});
return;
case 'error':
_logger().default.error({
origin: '@parcel/package-manager',
message: prefix(message.data)
});
return;
default: // ignore
}
});
try {
return await (0, _promiseFromProcess.default)(installProcess);
} catch (e) {
throw new Error('Yarn failed to install modules:' + e.message);
}
}
}
exports.Yarn = Yarn;
function prefix(message) {
return 'yarn: ' + message;
}
(0, _core().registerSerializableClass)(`${_package.default.version}:Yarn`, Yarn);