All files / src/lib/project ejectEngineToDir.ts

34.78% Statements 8/23
100% Branches 0/0
0% Functions 0/1
34.78% Lines 8/23

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 28 29 30 311x 1x 1x 1x 1x   1x   1x                                         1x  
import fs from "fs-extra";
import rimraf from "rimraf";
import { promisify } from "util";
import { engineRoot } from "consts";
import copy from "lib/helpers/fsCopy";
 
const rmdir = promisify(rimraf);
 
const ejectEngineToDir = async (ejectPath: string) => {
  const projectType = "gb";
  const enginePath = `${engineRoot}/${projectType}`;
  const engineSrcPath = `${enginePath}/src`;
  const engineIncludePath = `${enginePath}/include`;
  const engineMetaPath = `${enginePath}/engine.json`;
  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(engineMetaPath, ejectMetaPath);
};
 
export default ejectEngineToDir;