Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fallbackExclusionList.push({name: structUtils.requirableIdent(pkg), reference: pkg.reference});
const pnpSettings = {
blacklistedLocations,
dependencyTreeRoots,
enableTopLevelFallback,
fallbackExclusionList,
ignorePattern,
packageRegistry,
shebang,
virtualRoots,
};
const pnpUnpluggedFolder = this.opts.project.configuration.get(`pnpUnpluggedFolder`);
if (this.unpluggedPaths.size === 0) {
await xfs.removePromise(pnpUnpluggedFolder);
} else {
for (const entry of await xfs.readdirPromise(pnpUnpluggedFolder)) {
const unpluggedPath = ppath.resolve(pnpUnpluggedFolder, entry);
if (!this.unpluggedPaths.has(unpluggedPath)) {
await xfs.removePromise(unpluggedPath);
}
}
}
const nodeFs = new NodeFS(fs);
const baseFs = new ZipOpenFS({
baseFs: nodeFs,
maxOpenFiles: 80,
readOnlyArchives: true,
});
const defaultFsLayer: FakeFS = new VirtualFS({baseFs});
await xfs.removePromise(pnpDataPath);
} else {
const dataLocation = ppath.relative(ppath.dirname(pnpPath), pnpDataPath);
const {dataFile, loaderFile} = generateSplitScript({...pnpSettings, dataLocation});
await xfs.changeFilePromise(pnpPath, loaderFile);
await xfs.chmodPromise(pnpPath, 0o755);
await xfs.changeFilePromise(pnpDataPath, dataFile);
await xfs.chmodPromise(pnpDataPath, 0o644);
}
const pnpUnpluggedFolder = this.opts.project.configuration.get(`pnpUnpluggedFolder`);
if (this.unpluggedPaths.size === 0) {
await xfs.removePromise(pnpUnpluggedFolder);
} else {
for (const entry of await xfs.readdirPromise(pnpUnpluggedFolder)) {
const unpluggedPath = ppath.resolve(pnpUnpluggedFolder, entry);
if (!this.unpluggedPaths.has(unpluggedPath)) {
await xfs.removePromise(unpluggedPath);
}
}
}
}
enableTopLevelFallback,
fallbackExclusionList,
ignorePattern,
packageRegistry,
shebang,
virtualRoots,
};
const pnpUnpluggedFolder = this.opts.project.configuration.get(`pnpUnpluggedFolder`);
if (this.unpluggedPaths.size === 0) {
await xfs.removePromise(pnpUnpluggedFolder);
} else {
for (const entry of await xfs.readdirPromise(pnpUnpluggedFolder)) {
const unpluggedPath = ppath.resolve(pnpUnpluggedFolder, entry);
if (!this.unpluggedPaths.has(unpluggedPath)) {
await xfs.removePromise(unpluggedPath);
}
}
}
const nodeFs = new NodeFS(fs);
const baseFs = new ZipOpenFS({
baseFs: nodeFs,
maxOpenFiles: 80,
readOnlyArchives: true,
});
const defaultFsLayer: FakeFS = new VirtualFS({baseFs});
const rootPath = this.opts.project.cwd;
let prevLocatorMap: NodeModulesLocatorMap;
try {
prevLocatorMap = await readLocatorState(ppath.join(rootPath, NODE_MODULES, LOCATOR_STATE_FILE));
const binary = packageAccessibleBinaries.get(binaryName);
if (!binary)
throw new Error(`Binary not found (${binaryName}) for ${structUtils.prettyLocator(project.configuration, locator)}`);
const [, binaryPath] = binary;
const env = await makeScriptEnv({project});
for (const [binaryName, [, binaryPath]] of packageAccessibleBinaries)
await makePathWrapper(env.BERRY_BIN_FOLDER as PortablePath, toFilename(binaryName), process.execPath, [binaryPath]);
let result;
try {
result = await execUtils.pipevp(process.execPath, [binaryPath, ...args], {cwd, env, stdin, stdout, stderr});
} finally {
await xfs.removePromise(env.BERRY_BIN_FOLDER as PortablePath);
}
return result.code;
}
report.reportSeparator();
try {
await runWorkflow(UPDATE_WORKFLOW(this));
ready = true;
} catch (error) {
report.reportSeparator();
report.reportWarning(MessageName.UNNAMED, `Repository update failed; we'll try to regenerate it`);
}
}
if (!ready) {
report.reportInfo(MessageName.UNNAMED, `Cloning the remote repository`);
report.reportSeparator();
await xfs.removePromise(target);
await xfs.mkdirpPromise(target);
await runWorkflow(CLONE_WORKFLOW(this, target));
}
report.reportSeparator();
report.reportInfo(MessageName.UNNAMED, `Building a fresh bundle`);
report.reportSeparator();
await runWorkflow(BUILD_WORKFLOW(this));
report.reportSeparator();
const bundlePath = ppath.resolve(target, `packages/yarnpkg-cli/bundles/yarn.js` as PortablePath);
const bundleBuffer = await xfs.readFilePromise(bundlePath);
export async function executePackageShellcode(locator: Locator, command: string, args: Array, {cwd, project, stdin, stdout, stderr}: ExecutePackageScriptOptions) {
const {binFolder, env, cwd: realCwd} = await initializePackageEnvironment(locator, {project, cwd});
try {
return await execute(command, args, {cwd: realCwd, env, stdin, stdout, stderr});
} finally {
await xfs.removePromise(binFolder);
}
}
return;
const realExecutor = async () => {
return await execute(script, args, {cwd: realCwd, env, stdin, stdout, stderr});
};
const executor = await project.configuration.reduceHook(hooks => {
return hooks.wrapScriptExecution;
}, realExecutor, project, locator, scriptName, {
script, args, cwd: realCwd, env, stdin, stdout, stderr,
});
try {
return await executor();
} finally {
await xfs.removePromise(binFolder);
}
}
});
if (bstateData.length > 0) {
let bstateFile = `# Warning: This file is automatically generated. Removing it is fine, but will\n# cause all your builds to become invalidated.\n`;
for (const [locatorString, locatorHash, buildHash] of miscUtils.sortMap(bstateData, [d => d[0], d => d[1]])) {
bstateFile += `\n`;
bstateFile += `# ${locatorString}\n`;
bstateFile += `${JSON.stringify(locatorHash)}:\n`;
bstateFile += ` ${buildHash}\n`;
}
await xfs.mkdirpPromise(ppath.dirname(bstatePath));
await xfs.changeFilePromise(bstatePath, bstateFile);
} else {
await xfs.removePromise(bstatePath);
}
}
this.context.stdout.write(`\n`);
const configuration = await Configuration.find(tmpDir, this.context.plugins);
const {workspace} = await Project.find(configuration, tmpDir);
if (workspace === null)
throw new WorkspaceRequiredError(tmpDir);
return await scriptUtils.executeWorkspaceAccessibleBinary(workspace, command, this.args, {
cwd: this.context.cwd,
stdin: this.context.stdin,
stdout: this.context.stdout,
stderr: this.context.stderr,
});
} finally {
await xfs.removePromise(tmpDir);
}
}
}
blacklistedLocations,
dependencyTreeRoots,
enableTopLevelFallback,
fallbackExclusionList,
ignorePattern,
packageRegistry,
shebang,
};
if (this.opts.project.configuration.get(`pnpEnableInlining`)) {
const loaderFile = generateInlinedScript(pnpSettings);
await xfs.changeFilePromise(pnpPath, loaderFile);
await xfs.chmodPromise(pnpPath, 0o755);
await xfs.removePromise(pnpDataPath);
} else {
const dataLocation = ppath.relative(ppath.dirname(pnpPath), pnpDataPath);
const {dataFile, loaderFile} = generateSplitScript({...pnpSettings, dataLocation});
await xfs.changeFilePromise(pnpPath, loaderFile);
await xfs.chmodPromise(pnpPath, 0o755);
await xfs.changeFilePromise(pnpDataPath, dataFile);
await xfs.chmodPromise(pnpDataPath, 0o644);
}
const pnpUnpluggedFolder = this.opts.project.configuration.get(`pnpUnpluggedFolder`);
if (this.unpluggedPaths.size === 0) {
await xfs.removePromise(pnpUnpluggedFolder);
} else {
for (const entry of await xfs.readdirPromise(pnpUnpluggedFolder)) {