本文整理汇总了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()
}
})
示例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);
}
}
示例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
示例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 });
};
示例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()
}