当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fs-extra.moveSync函数代码示例

本文整理汇总了TypeScript中fs-extra.moveSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript moveSync函数的具体用法?TypeScript moveSync怎么用?TypeScript moveSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了moveSync函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: resolve

 .on('complete', () => {
   const downloadTempPath = path.join(appPath, downloadTemp)
   if (fs.existsSync(downloadTempPath)) {
     fs.moveSync(downloadTempPath, path.join(dest, downloadTemp))
     resolve()
   }
 })
开发者ID:YangShaoQun,项目名称:taro,代码行数:7,代码来源:dowload.ts

示例2: createProject

async function createProject(projectPath: string, truffleBoxName: string): Promise<void> {
  await fs.ensureDir(projectPath);

  const arrayFiles =  await fs.readdir(projectPath);
  const path = (arrayFiles.length) ? createTemporaryDir(projectPath) : projectPath;

  try {
    window.showInformationMessage(Constants.informationMessage.newProjectCreationStarted);
    Output.show();
    await outputCommandHelper.executeCommand(path, 'npx', 'truffle', 'unbox', truffleBoxName);
    if (arrayFiles.length) {
      fs.moveSync(path, projectPath);
    }
    workspace.updateWorkspaceFolders(
      0,
      workspace.workspaceFolders ? workspace.workspaceFolders.length : null,
      {uri: Uri.file(projectPath)});
    window.showInformationMessage(Constants.informationMessage.newProjectCreationFinished);
  } catch (error) {
    // TODO: cleanup files after failed truffle unbox
    throw Error(error);
  }
}
开发者ID:chrisseg,项目名称:vscode-azure-blockchain-ethereum,代码行数:23,代码来源:ProjectCommands.ts

示例3:

const data = "";
const uid = 0;
const gid = 0;
const fd = 0;
const modeNum = 0;
const modeStr = "";
const object = {};
const errorCallback = (err: Error) => { };
const readOptions: fs.ReadOptions = {
	reviver: {}
};
const writeOptions: fs.WriteOptions = {
	replacer: {}
};

fs.moveSync(src, dest, {});
fs.move(src, dest, {}).then(() => {
	// stub
});
fs.move(src, dest).then(() => {
	// stub
});
fs.move(src, dest, {}, () => {
	// stub
});
fs.move(src, dest, () => {
	// stub
});

fs.copy(src, dest).then(() => {
	// stub
开发者ID:gilamran,项目名称:DefinitelyTyped,代码行数:31,代码来源:fs-extra-tests.ts

示例4: join

export = () => {
  const originalFile = join(config.SERVER_STATIC_SRC, 'client', 'index.html');
  const indexFile = join(config.SERVER_TEMPLATES_SRC, 'index.html');
  moveSync(originalFile, indexFile, { overwrite: true });
};
开发者ID:our-city-app,项目名称:gae-plugin-framework,代码行数:5,代码来源:build.prod.move.ts

示例5: buildWxPlugin

async function buildWxPlugin (appPath, { watch }) {
  const {
    sourceDir,
    outputDir
  } = setBuildData(appPath, BUILD_TYPES.WEAPP)
  const pluginDir = path.join(sourceDir, PLUGIN_ROOT)
  const pluginPath = path.join(appPath, PLUGIN_ROOT)
  const docDir = path.join(pluginDir, DOC_ROOT)
  const docPath = path.join(appPath, DOC_ROOT)

  fs.existsSync(pluginPath) && Util.emptyDirectory(pluginPath)
  fs.existsSync(docPath) && Util.emptyDirectory(docPath)
  // 编译调试项目
  await buildWeapp(appPath, { adapter: BUILD_TYPES.WEAPP, envHasBeenSet: true })

  const pluginJsonPath = path.join(pluginDir, PLUGIN_JSON)
  if (!fs.existsSync(pluginDir) || !fs.existsSync(pluginJsonPath)) {
    return console.log(chalk.red('缺少 plugin.json!'))
  }
  const pluginJson = fs.readJSONSync(pluginJsonPath)
  const components = pluginJson.publicComponents
  const pages: { [key: string]: any } = pluginJson.pages
  const main = pluginJson.main

  // 编译插件页面
  if (pages && Object.keys(pages).length) {
    Util.printLog(processTypeEnum.COMPILE, '插件页面')
    const pagesPromises = Object.values(pages).map(page => buildSinglePage(path.join(PLUGIN_ROOT, page)))
    await Promise.all(pagesPromises)
  }

  // 编译插件组件
  if (components && Object.keys(components).length) {
    Util.printLog(processTypeEnum.COMPILE, '插件组件')
    const componentList: any[] = []
    for (const component in components) {
      const componentPath = components[component]
      componentList.push({
        path: /^(\.|\/)/.test(componentPath) ? componentPath : '.' + path.sep + componentPath,
        name: component,
        type: 'default'
      })
    }
    const realComponentsPathList = getRealComponentsPathList(pluginJsonPath, componentList)
    await buildDepComponents(realComponentsPathList)
  }

  // 编译插件 main.js
  if (main) {
    Util.printLog(processTypeEnum.COMPILE, '插件 JS')
    await Promise.all(compileDepScripts([path.join(pluginDir, main)], true, true))
  }

  // 把 plugin 目录挪到根目录
  fs.moveSync(path.join(outputDir, PLUGIN_ROOT), pluginPath)
  // 把 npm 拷贝一份到 plugin 目录
  fs.copySync(path.join(outputDir, NPM_DIR), path.join(pluginPath, NPM_DIR))
  // 把 doc 目录拷贝到根目录
  fs.existsSync(docDir) && fs.copySync(docDir, docPath)
  // 拷贝 plugin.json
  compilePluginJson(pluginJson, path.join(pluginPath, PLUGIN_JSON))

  // plugin 文件夹内对 npm 的引用路径修改
  const names = glob.sync('plugin/{,!(npm)/**/}*.js')
  const ioPromises = names.map(name => {
    const content = fs.readFileSync(name).toString()

    let isShouldBeWritten
    let replacement = content.replace(/['|"]((\.\.\/)+)npm\/.+?['|"]/g, (str, $1) => {
      isShouldBeWritten = true
      return $1 === '../' ? str.replace('../', './') : str.replace('../', '')
    })

    const REG_PLUGIN_DEPS = RegExp(`['|"](/${PLUGIN_ROOT}.+)['|"]`, 'g')
    replacement = replacement.replace(REG_PLUGIN_DEPS, (str, $1) => {
      if (REG_FONT.test($1) || REG_IMAGE.test($1) || REG_MEDIA.test($1)) {
        return str.replace(RegExp(`^['|"]/${PLUGIN_ROOT}`, 'g'), str => str.replace(`${PLUGIN_ROOT}`, ''))
      }
      return str
    })

    if (isShouldBeWritten) fs.writeFileSync(path.join(appPath, name), replacement)
  })
  await Promise.all(ioPromises)

  watch && wxPluginWatchFiles()
}
开发者ID:YangShaoQun,项目名称:taro,代码行数:87,代码来源:plugin.ts


注:本文中的fs-extra.moveSync函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。