Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static load({
base,
path,
content,
indent,
newline,
override = true
}: {
base: string;
path: string;
content: Record;
indent?: string | null | undefined;
newline?: string | null | undefined;
override?: boolean;
}): PackageJsonVinyl {
const jsonStr = stringifyPackage(content, indent, newline);
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
const jsonFile = new PackageJsonVinyl({ base, path, contents: Buffer.from(jsonStr) });
jsonFile.override = override;
return jsonFile;
}
}
async write() {
if (!this.workspaceDir) throw new Error('PackageJsonFile is unable to write, workspaceDir is not defined');
const pathToWrite = path.join(this.workspaceDir, this.filePath);
logger.debug(`package-json-file.write, path ${pathToWrite}`);
const packageJsonStr = stringifyPackage(this.packageJsonObject, this.indent, this.newline);
await fs.outputFile(pathToWrite, packageJsonStr);
this.fileExist = true;
}
async write() {
if (!this.workspaceDir) throw new Error('PackageJsonFile is unable to write, workspaceDir is not defined');
const pathToWrite = path.join(this.workspaceDir, this.filePath);
logger.debug(`package-json-file.write, path ${pathToWrite}`);
const packageJsonStr = stringifyPackage(this.packageJsonObject, this.indent, this.newline);
await fs.outputFile(pathToWrite, packageJsonStr);
this.fileExist = true;
}