All files / src/lib/project ejectEngineToDir.ts

40% Statements 8/20
100% Branches 0/0
0% Functions 0/1
40% Lines 8/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 281x 1x 1x 1x 1x   1x   1x                                   1x  
import fs from "fs-extra";
import rimraf from "rimraf";
import { promisify } from "util";
import { defaultEngineMetaPath, defaultEngineRoot } from "consts";
import copy from "lib/helpers/fsCopy";
 
const rmdir = promisify(rimraf);
 
const ejectEngineToDir = async (ejectPath: string) => {
  const engineSrcPath = `${defaultEngineRoot}/src`;
  const engineIncludePath = `${defaultEngineRoot}/include`;
  const ejectSrcPath = `${ejectPath}/src`;
  const ejectIncludePath = `${ejectPath}/include`;
  const ejectMetaPath = `${ejectPath}/engine.json`;
 
  await rmdir(ejectPath);
 
  await fs.ensureDir(ejectPath);
  await fs.ensureDir(ejectSrcPath);
  await fs.ensureDir(ejectIncludePath);
 
  await copy(engineSrcPath, ejectSrcPath);
  await copy(engineIncludePath, ejectIncludePath);
  await copy(defaultEngineMetaPath, ejectMetaPath);
};
 
export default ejectEngineToDir;