How to use the @ionic/utils-fs.copy function in @ionic/utils-fs

To help you get started, we’ve selected a few @ionic/utils-fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ionic-team / native-run / src / android / utils / avd.ts View on Github external
export async function copySkin(sdk: SDK, skin: string, skinpath: string): Promise {
  const debug = Debug(`${modulePrefix}:${copySkin.name}`);
  const skinsrc = pathlib.resolve(ASSETS_PATH, 'android', 'skins', skin);

  const stat = await statSafe(skinsrc);

  if (stat && stat.isDirectory()) {
    debug('Copying skin from %s to %s', skinsrc, skinpath);

    try {
      return await copy(skinsrc, skinpath);
    } catch (e) {
      debug('Error while copying skin: %O', e);
    }
  }

  throw new AVDException(`${skinpath} is an invalid skin.`, ERR_INVALID_SKIN);
}
github ionic-team / starters / src / lib / build.ts View on Github external
export async function buildStarter(ionicType: string, starterType: string, starterDir: string): Promise {
  const id = buildStarterId(ionicType, starterType, starterDir);
  const baseDir = path.resolve(REPO_DIRECTORY, ionicType, 'base');
  const tmpdest = path.resolve(BUILD_DIRECTORY, id);

  log(id, 'Building...');

  const manifest = await readStarterManifest(starterDir);

  if (!manifest) {
    throw new Error(`No starter manifest found in ${starterDir}`);
  }

  await copy(baseDir, tmpdest, {});
  await copy(starterDir, tmpdest, {});

  try {
    await remove(path.resolve(tmpdest, '.git'));
  } catch (e) {
    if (e.code !== 'ENOENT') {
      throw e;
    }
  }

  const pkgPath = path.resolve(tmpdest, 'package.json');
  const pkg = await readPackageJsonFile(pkgPath);

  log(id, `Performing manifest operations for ${chalk.bold(manifest.name)}`);

  if (manifest.packageJson) {
github ionic-team / ionic-cli / packages / ionic / src / lib / integrations / cordova / index.ts View on Github external
if (!overwrite) {
          blacklist.push(f);
        }
      } catch (e) {
        if (e.code !== 'ENOENT') {
          throw e;
        }
      }
    }

    this.e.log.info(`Copying integrations files to project`);
    debug(`Blacklist: ${blacklist.map(f => strong(f)).join(', ')}`);

    await mkdirp(details.root);

    await copy(tmpdir, details.root, {
      filter: f => {
        if (f === tmpdir) {
          return true;
        }

        const projectf = f.substring(tmpdir.length + 1);

        for (const item of blacklist) {
          if (item.slice(-1) === '/' && `${projectf}/` === item) {
            return false;
          }

          if (projectf.startsWith(item)) {
            return false;
          }
        }
github ionic-team / starters / src / lib / build.ts View on Github external
export async function buildStarter(ionicType: string, starterType: string, starterDir: string): Promise {
  const id = buildStarterId(ionicType, starterType, starterDir);
  const baseDir = path.resolve(REPO_DIRECTORY, ionicType, 'base');
  const tmpdest = path.resolve(BUILD_DIRECTORY, id);

  log(id, 'Building...');

  const manifest = await readStarterManifest(starterDir);

  if (!manifest) {
    throw new Error(`No starter manifest found in ${starterDir}`);
  }

  await copy(baseDir, tmpdest, {});
  await copy(starterDir, tmpdest, {});

  try {
    await remove(path.resolve(tmpdest, '.git'));
  } catch (e) {
    if (e.code !== 'ENOENT') {
      throw e;
    }
  }

  const pkgPath = path.resolve(tmpdest, 'package.json');
  const pkg = await readPackageJsonFile(pkgPath);

  log(id, `Performing manifest operations for ${chalk.bold(manifest.name)}`);

  if (manifest.packageJson) {
    _.mergeWith(pkg, manifest.packageJson, (objv, v) => _.isArray(v) ? v : undefined);