當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。