fs-extra#outputJSON TypeScript Examples
The following examples show how to use
fs-extra#outputJSON.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestProject.ts From yarn-plugins with MIT License | 6 votes |
public static async setup(): Promise<TestProject> {
const dir = await tmp.dir();
const pluginBundles = await globby('packages/*/bundles/**/*.js', {
cwd: PROJECT_DIR,
});
const plugins = pluginBundles.map((src) => ({
src,
name: '@yarnpkg/' + basename(src, extname(src)),
dest: posix.join('.yarn', 'plugins', ...src.split(sep).slice(3)),
}));
for (const path of plugins) {
await copy(join(PROJECT_DIR, path.src), join(dir.path, path.dest));
}
const yarnConfig = safeLoad(
await readFile(join(PROJECT_DIR, '.yarnrc.yml'), 'utf8'),
) as Record<string, unknown>;
// Create .yarnrc.yml
await outputFile(
join(dir.path, '.yarnrc.yml'),
safeDump({
yarnPath: join(PROJECT_DIR, yarnConfig.yarnPath as string),
plugins: plugins.map((plugin) => ({
path: plugin.dest,
spec: plugin.name,
})),
}),
);
// Create package.json
await outputJSON(join(dir.path, 'package.json'), {
private: true,
workspaces: ['packages/*'],
});
return new TestProject(dir);
}
Example #2
Source File: TestWorkspace.ts From yarn-plugins with MIT License | 6 votes |
public static async setup(
project: TestProject,
name: string,
): Promise<TestWorkspace> {
const ws = new TestWorkspace(project, name);
// Create package.json
await outputJSON(join(ws.path, 'package.json'), {
name,
private: true,
});
return ws;
}
Example #3
Source File: DownloadedUpdateHelper.ts From electron-differential-updater with MIT License | 6 votes |
async setDownloadedFile(downloadedFile: string, packageFile: string | null, versionInfo: UpdateInfo, fileInfo: ResolvedUpdateFileInfo, updateFileName: string, isSaveCache: boolean): Promise<void> {
this._file = downloadedFile
this._packageFile = packageFile
this.versionInfo = versionInfo
this.fileInfo = fileInfo
this._downloadedFileInfo = {
fileName: updateFileName,
sha512: fileInfo.info.sha512,
isAdminRightsRequired: fileInfo.info.isAdminRightsRequired === true,
}
if (isSaveCache) {
await outputJson(this.getUpdateInfoFile(), this._downloadedFileInfo)
}
}
Example #4
Source File: index.ts From yarn-plugins with MIT License | 5 votes |
async function writeTsConfig(ws: TestWorkspace, data: unknown): Promise<void> {
await outputJSON(getTsConfigPath(ws), data);
}