0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/test/e2e-cli/utils/utils.ts

33 lines
892 B
TypeScript
Raw Normal View History

import fs from 'fs-extra';
import os from 'os';
import path from 'path';
2019-12-15 11:06:28 -05:00
export function createProject(projectName: string) {
// @ts-ignore
const tempRootFolder = global.__namespace.getItem('dir-suite-root');
const verdaccioInstall = path.join(tempRootFolder, projectName);
fs.mkdirSync(verdaccioInstall);
return verdaccioInstall;
}
2019-12-15 11:06:28 -05:00
export function copyConfigFile(rootFolder, configTemplate): string {
const configPath = path.join(rootFolder, 'verdaccio.yaml');
copyTo(path.join(__dirname, configTemplate), configPath);
2019-12-15 11:06:28 -05:00
return configPath;
2019-12-15 11:06:28 -05:00
}
export function createTempFolder(prefix: string) {
return fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), prefix));
}
export function copyTo(from, to) {
fs.copyFileSync(from, to);
}
export function cleanUpTemp(tmpFolder) {
fs.rmdirSync(tmpFolder, { recursive: true });
}
export const SETUP_VERDACCIO_PORT = `6001`;