本文整理匯總了TypeScript中ncp.ncp函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript ncp函數的具體用法?TypeScript ncp怎麽用?TypeScript ncp使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ncp函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
async.eachSeries(links, function(link: string, cb2: (err?: any) => void): void {
try {
var dest = fs.readlinkSync(link);
if (dest.match(/^\/etc/)) {
ncp(path.join(grunt.config('build.scratch_dir'), dest), link, function(err?: any) {
if (err) {
// Some /etc symlinks are just broken. Hopefully not a big deal.
grunt.log.writeln('warning: broken symlink: ' + dest);
}
cb2(null);
});
} else {
var p = path.resolve(path.join(path.dirname(link), dest));
// copy in anything that links out of the JH dir
if (p.indexOf(dir_name) === -1) {
// XXX: this fails if two symlinks reference the same file
if (fs.statSync(p).isDirectory()) {
fs.unlinkSync(link);
}
ncp(p, link, function(err?: any) {
if (err) {
grunt.log.writeln('warning: broken symlink: ' + p);
}
cb2(null);
});
} else {
// Nothing to do.
cb2(null);
}
}
} catch (e) {
grunt.log.writeln('warning: broken symlink: ' + link);
cb2(null);
}
}, function(err: any): void {
示例2: function
function(resolve, reject){
ncp(source, destination, function(err){
if(err){
reject(err);
}
resolve();
})
});
示例3: resolve
checksum.file(dst, (dstErr, dstSum) => {
if (srcSum === dstSum) {
console.log(`[unchanged]:${filename}`);
return resolve(`${filename} unchanged`);
}
// copy on error or checksum diffs
ncp(src, dst, err => {
if (err) {
reject(`failed to copy octicon: ${filename}`);
} else {
console.log(`[icon]:${filename}`);
resolve(`${filename} copied`);
}
});
});
示例4: copySchematicsCore
export async function copySchematicsCore(config: Config) {
(ncp as any).limit = 1;
for (let pkg of util.getTopLevelPackages(config)) {
const packageJson = fs
.readFileSync(`${modulesDir}${pkg}/package.json`)
.toString('utf-8');
const pkgConfig = JSON.parse(packageJson);
if (pkgConfig.schematics || pkgConfig['ng-update'].migrations) {
ncp(
`${modulesDir}/schematics-core`,
`${modulesDir}/${pkg}/schematics-core`,
function(err: any) {
if (err) {
return console.error(err);
}
}
);
}
}
}
示例5: Promise
await new Promise((c, e) => ncp(logsDir, destLogsDir, err => err ? e(err) : c()));
示例6: ncp
return new Promise<string>((resolve) => {
ncp(data.src,data.dest,(err)=>{
if (err) console.log('Move failed', err);
resolve(JSON.stringify(err));
});
});
示例7: function
}, function(err: any): void {
ncp(JH, java_home, function(err2?: any): void {
err2 = err2 ? err2 : err;
cb(err2);
});
});
示例8: function
}, function(err){
ncp(JH, java_home, function(err2?: any) {
err2 = err2 ? err2 : err;
cb(err2);
});
});