Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// First, create the main cache directory if necessary.
await fs.mkdirp(dir);
// In parallel, create sub-directories for every possible hex value
// This speeds up large caches on many file systems since there are fewer files in a single directory.
let dirPromises = [];
for (let i = 0; i < 256; i++) {
dirPromises.push(
fs.mkdirp(path.join(dir, ('00' + i.toString(16)).slice(-2))),
);
}
await Promise.all(dirPromises);
}
registerSerializableClass(`${packageJson.version}:Cache`, Cache);
function register(ctor: Class<*>): void {
registerSerializableClass(packageVersion + ':' + ctor.name, ctor);
}
return deserialize(response.body);
}
async set(key: string, value: mixed) {
await this.request(this._getCachePath(key), {
method: 'put',
body: serialize(value),
headers: {
'content-type': 'application/octet-stream'
}
});
return key;
}
}
registerSerializableClass(`${packageJson.version}:HTTPCache`, HTTPCache);
super.rimraf(filePath);
return this.handleFn('rimraf', [filePath]);
}
ncp(source: FilePath, destination: FilePath) {
super.ncp(source, destination);
return this.handleFn('ncp', [source, destination]);
}
symlink(target: FilePath, path: FilePath) {
super.symlink(target, path);
return this.handleFn('symlink', [target, path]);
}
}
registerSerializableClass(`${packageJSON.version}:MemoryFS`, MemoryFS);
registerSerializableClass(`${packageJSON.version}:WorkerFS`, WorkerFS);
registerSerializableClass(`${packageJSON.version}:Stat`, Stat);
registerSerializableClass(`${packageJSON.version}:File`, File);
registerSerializableClass(`${packageJSON.version}:Directory`, Directory);
ncp(source: FilePath, destination: FilePath) {
super.ncp(source, destination);
return this.handleFn('ncp', [source, destination]);
}
symlink(target: FilePath, path: FilePath) {
super.symlink(target, path);
return this.handleFn('symlink', [target, path]);
}
}
registerSerializableClass(`${packageJSON.version}:MemoryFS`, MemoryFS);
registerSerializableClass(`${packageJSON.version}:WorkerFS`, WorkerFS);
registerSerializableClass(`${packageJSON.version}:Stat`, Stat);
registerSerializableClass(`${packageJSON.version}:File`, File);
registerSerializableClass(`${packageJSON.version}:Directory`, Directory);
logger.log({
origin: '@parcel/package-manager',
message,
});
}
} catch (e) {
throw new Error('npm failed to install modules');
}
}
}
type NPMResults = {|
added: Array<{name: string, ...}>,
|};
registerSerializableClass(`${pkg.version}:Npm`, Npm);
snapshot,
opts,
);
return [...writableEvents, ...readableEvents];
}
async writeSnapshot(
dir: FilePath,
snapshot: FilePath,
opts: WatcherOptions,
): Promise {
await this.writable.writeSnapshot(dir, snapshot, opts);
}
}
registerSerializableClass(`${packageJSON.version}:OverlayFS`, OverlayFS);
}
ncp(source: FilePath, destination: FilePath) {
super.ncp(source, destination);
return this.handleFn('ncp', [source, destination]);
}
symlink(target: FilePath, path: FilePath) {
super.symlink(target, path);
return this.handleFn('symlink', [target, path]);
}
}
registerSerializableClass(`${packageJSON.version}:MemoryFS`, MemoryFS);
registerSerializableClass(`${packageJSON.version}:WorkerFS`, WorkerFS);
registerSerializableClass(`${packageJSON.version}:Stat`, Stat);
registerSerializableClass(`${packageJSON.version}:File`, File);
registerSerializableClass(`${packageJSON.version}:Directory`, Directory);
snapshot: FilePath,
opts: WatcherOptions,
): Promise {
await watcher.writeSnapshot(dir, snapshot, opts);
}
static deserialize() {
return new NodeFS();
}
serialize() {
return null;
}
}
registerSerializableClass(`${packageJSON.version}:NodeFS`, NodeFS);
}
});
try {
return await promiseFromProcess(installProcess);
} catch (e) {
throw new Error('Yarn failed to install modules');
}
}
}
function prefix(message: string): string {
return 'yarn: ' + message;
}
registerSerializableClass(`${pkg.version}:Yarn`, Yarn);