本文整理匯總了TypeScript中fs-extra.copySync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript copySync函數的具體用法?TypeScript copySync怎麽用?TypeScript copySync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了copySync函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Error
schemas.forEach(schema => {
const file = path.basename(schema);
if (file === 'package.json') {
throw new Error('Cannot use name "package.json" for schema file');
}
fs.copySync(schema, path.join(destination, file));
});
示例2: assertDirsEqual
function assertDirsEqual(actual: string, expected: string, basedir = actual) {
if (process.env['UPDATE_POLYMER_CLI_GOLDENS']) {
fsExtra.emptyDirSync(expected);
fsExtra.copySync(actual, expected);
throw new Error('Goldens updated, test failing for your safety.');
}
const actualNames = fs.readdirSync(actual).sort();
const expectedNames = fs.readdirSync(expected).sort();
assert.deepEqual(
actualNames,
expectedNames,
`expected files in directory ${path.relative(basedir, actual)}`);
for (const fn of actualNames) {
const subActual = path.join(actual, fn);
const subExpected = path.join(expected, fn);
const stat = fs.statSync(subActual);
if (stat.isDirectory()) {
assertDirsEqual(subActual, subExpected, basedir);
} else {
const actualContents = fs.readFileSync(subActual, 'utf-8').trim();
const expectedContents = fs.readFileSync(subExpected, 'utf-8').trim();
assert.deepEqual(
actualContents,
expectedContents,
`expected contents of ${path.relative(basedir, subActual)}`);
}
}
}
示例3: updateGhPagesAsync
static async updateGhPagesAsync(
repoUrl: string,
siteFolder: string,
docfxExe: string,
docfxJson: string,
gitUserName: string,
gitUserEmail: string,
gitCommitMessage: string) {
Guard.argumentNotNullOrEmpty(repoUrl, "repoUrl");
Guard.argumentNotNullOrEmpty(siteFolder, "siteFolder");
Guard.argumentNotNullOrEmpty(docfxExe, "docfxExe");
Guard.argumentNotNullOrEmpty(docfxJson, "docfxJson");
Guard.argumentNotNullOrEmpty(gitUserName, "gitUserName");
Guard.argumentNotNullOrEmpty(gitUserEmail, "gitUserEmail");
Guard.argumentNotNullOrEmpty(gitCommitMessage, "gitCommitMessage");
await Common.execAsync(docfxExe, [docfxJson]);
let branch = "gh-pages";
let targetDir = "docfxsite";
this.cleanGitInfo(siteFolder);
await Common.execAsync("git", ["clone", repoUrl, "-b", branch, targetDir]);
fs.mkdirsSync(path.join(siteFolder, ".git"));
fs.copySync(path.join(targetDir, ".git"), path.join(siteFolder, ".git"));
await Common.execAsync("git", ["config", "user.name", gitUserName], siteFolder);
await Common.execAsync("git", ["config", "user.email", gitUserEmail], siteFolder);
await Common.execAsync("git", ["add", "."], siteFolder);
await Common.execAsync("git", ["commit", "-m", gitCommitMessage], siteFolder);
return Common.execAsync("git", ["push", "origin", branch], siteFolder);
}
示例4: isAbsolute
files.forEach((fileName) => {
const sourcePath = isAbsolute(fileName) ? fileName : resolve(path, fileName);
const destFileName = isAbsolute(fileName) ? basename(fileName) : fileName;
const destPath = resolve(cwd, copiedFilesDir, commandName, destFileName);
console.log(` ${yellow('creating')} ${destPath.replace(cwd, '.')}`);
copySync(sourcePath, destPath);
});
示例5: async
const copyPublicFolder = async (dest: string): Promise<void> => {
if (await fs.pathExists(paths.appPublic)) {
await fs.copySync(paths.appPublic, paths.distPublic(dest), {
dereference: true,
filter: file => file !== paths.indexHtml,
})
}
}
示例6: generateMission
export function generateMission(terrainId: string): Mission.GeneratedMission {
var mission = defaultMission(terrainId);
var generatedMission = Mission.generateMission(mission);
updateMissionSqm(`${generatedMission.missionDir}/mission.sqm`);
updateDescriptionExt(`${generatedMission.missionDir}/description.ext`);
fs.copySync(`${TS_HOME}/blufor_briefing.sqf`, `${generatedMission.missionDir}/hull3/briefing/blufor.sqf`);
return generatedMission;
}
示例7: Promise
return new Promise((resolve, reject) => {
try {
fse.copySync(srcDir, destDir, options);
resolve();
} catch (e) {
reject(e);
}
});
示例8:
.then(() => {
FS.copySync(tmpPackagePath, packagePath);
let metadataJSON = JSON.stringify(metadata, undefined, 4);
FS.writeFileSync(metadataFilePath, metadataJSON);
return packagePath;
});
示例9: copy
export function copy(src: string, dest: string) {
// Log.info(`./> cp ${src} ${dest}`);
try {
fse.copySync(src, dest);
} catch (e) {
Log.error(`copy: ${e.message}`);
}
}
示例10: generateMission
export function generateMission(terrainId: string): Mission.GeneratedMission {
var mission = defaultMission(terrainId);
var generatedMission = Mission.generateMission(mission);
var missionSqmPath = `${generatedMission.missionDir}/mission.sqm`;
var missionAst = updateMissionSqm(missionSqmPath);
var maxPlayers = Mission.getPlayableUnitCount(missionAst);
var fullMissionName = `ark_${Mission.missionTypeToMissionNamePrefix(Mission.stringToMissionType(mission.missionTypeName))}${maxPlayers}_${mission.briefingName.toLowerCase()}`;
updateDescriptionExt(`${generatedMission.missionDir}/description.ext`, maxPlayers);
generatedMission.downloadMissionName = `${fullMissionName}.${mission.terrainId}`;
Ast.select(missionAst, 'ScenarioData.Header.maxPlayers')[0].value = maxPlayers;
Ast.select(missionAst, 'Mission.Intel.briefingName')[0].value = fullMissionName;
fs.writeFileSync(missionSqmPath, PrettyPrinter.create('\t').print(missionAst), 'UTF-8');
fs.copySync(`${RE_HOME}/blufor_briefing.sqf`, `${generatedMission.missionDir}/hull3/briefing/blufor.sqf`);
fs.copySync(`${RE_HOME}/opfor_briefing.sqf`, `${generatedMission.missionDir}/hull3/briefing/opfor.sqf`);
return generatedMission;
}
示例11: html
export function html(dest: string = '.') {
const templateDir = path.resolve(
path.join(__dirname, '..', 'templates', 'html')
);
const destDir = path.resolve(dest);
fs.copySync(templateDir, destDir, {
filter: fileCopyFilter
});
}
示例12:
.action(function (dir, options) {
let sdir = dir;
dir = cmd.emptydir(dir);
fs.copySync(path.join(Setting.test_items_dir, 'example'), dir);
fs.removeSync(path.join(dir,'__check__'));
console.log(`Project successfully created.`);
console.log(`To use: '${program.name()} --indir ${sdir} --outdir <outdir>'`);
console.log(`We recommend add in a file 'package.json' => script: {"build-mcgen": "${program.name()} --indir ${sdir} --outdir <outdir>"}`);
process.exit(0);
});
示例13: copySound
async copySound(platform: string, from: string, to: string, options: any) {
if (options.quality < 1) {
fs.ensureDirSync(path.join(this.options.to, this.sysdir(), this.safename, 'app', 'src', 'main', 'assets', path.dirname(to)));
let ogg = await convert(from, path.join(this.options.to, this.sysdir(), this.safename, 'app', 'src', 'main', 'assets', to + '.ogg'), this.options.ogg);
return [to + '.ogg'];
}
else {
fs.copySync(from.toString(), path.join(this.options.to, this.sysdir(), this.safename, 'app', 'src', 'main', 'assets', to + '.wav'), { overwrite: true });
return [to + '.wav'];
}
}
示例14: generate
public generate() {
this.cloneTemplate();
const dir = this.config.name;
const templateRepo = PlatformConfig.getRepository();
const templateProjectName = GitGen.getRepoName(templateRepo.client);
const replacePattern = { [templateProjectName]: dir };
copySync(`${dir}/resources/gitignore/variantConfig.ts`, `${dir}/src/config/variantConfig.ts`);
// for installing plugins this folder must exist
mkdirSync(`${dir}/vesta/cordova/www`);
findInFileAndReplace(`${dir}/vesta/cordova/config.xml`, replacePattern);
}
示例15: copyProjectConfig
/**
* 拷貝小程序項目配置文件
*
* @private
* @memberof Xcx
*/
private copyProjectConfig () {
let src = path.join(config.cwd, MINI_PROGRAM_CONFIG_FILE_NAME)
let dest = config.getPath('dest', MINI_PROGRAM_CONFIG_FILE_NAME)
if (!fs.existsSync(src)) {
return
}
log.newline()
log.msg(LogType.COPY, MINI_PROGRAM_CONFIG_FILE_NAME)
fs.copySync(src, dest)
}