本文整理匯總了TypeScript中fs.symlink函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript symlink函數的具體用法?TypeScript symlink怎麽用?TypeScript symlink使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了symlink函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: lstat
lstat(sourcePath, (error, sourceStats) => {
if (error) return callback(error);
if (sourceStats.isDirectory()) {
// if source is a directory, mkdir a new directory at targetPath and recurse
mkdir_p(targetPath, error => {
if (error) return callback(error);
readdir(sourcePath, (error, files) => {
if (error) return callback(error);
const sourcePairs = files.map(file => [file, join(sourcePath, file)]);
const includedSourcePairs = sourcePairs.filter(([_, source]) => !ignoreFunction(source));
async.each(includedSourcePairs, ([file, source], callback) => {
const target = join(targetPath, file);
link(source, target, ignoreFunction, callback);
}, callback);
});
});
}
else if (sourceStats.isSymbolicLink() || sourceStats.isFile()) {
log(`${sourcePath} <- ${targetPath}`);
// type declarations are incorrect; symlink should be overloaded with three arguments
symlink(sourcePath, targetPath, null, callback);
}
else {
callback(new Error(`Cannot link unusual source file: "${sourcePath}"`));
}
});
示例2: createSymbolicToNode
// create symbolic
static createSymbolicToNode(name: string) {
// let userPath = __dirname + "/../../node_modules/app/models/ScriptServer.js";
// let execPath = __dirname + "/../../app/models/ScriptServer.js";
let userPath = __dirname + "/../../node_modules/app";
let execPath = __dirname + "/../../app";
let fs = require("fs");
if (!fs.existsSync(userPath)) {
fs.symlink(execPath, userPath, (err) => {
console.log(err || "Done.");
});
}
}
示例3: createScriptPath
// create symbolic link to Script.js to angular & command line tools
static createScriptPath() {
let userPath = Electron.app.getPath("userData") + "/Script.js";
// let execPath = __dirname + "/../../build/app.js";
let execPath = __dirname + "/Script.js";
let fs = require("fs");
if (!fs.existsSync(userPath)) {
fs.symlink(execPath, userPath, (err) => {
console.log(err || "Done.");
});
}
}
示例4: function
grunt.registerTask('_link', '', function (this: ITask) {
const done = this.async();
const packagePath = pkgDir.sync(process.cwd());
const targetPath = grunt.config('distDirectory');
fs.symlink(
path.join(packagePath, 'node_modules'),
path.join(targetPath, 'node_modules'),
'junction',
() => {}
);
fs.symlink(
path.join(packagePath, 'package.json'),
path.join(targetPath, 'package.json'),
'file',
() => {}
);
execa.shell('npm link', { cwd: targetPath })
.then((result: any) => grunt.log.ok(result.stdout))
.then(done);
});
示例5: create
static create() {
let userPath = Electron.app.getPath("userData") + "/Script.js";
let execPath = __dirname + "/Script.js";
// if already exists, skip create a symlink
let fs = require("fs");
let stats = fs.lstatSync(userPath);
if (!stats.isSymbolicLink()) {
fs.symlink(execPath, userPath, (err) => {
console.log(err || "Done.");
});
}
}
示例6: Promise
return new Promise((resolve, reject) => {
fs.symlink(target, this.path, err => {
err ? reject(err) : resolve();
});
});
示例7: Promise
await new Promise((c, e) => fs.symlink(debug2Path, path.join(app.extensionsPath, 'vscode-node-debug2'), err => err ? e(err) : c()));
示例8:
import pathHelper from '../helpers/pathHelper';
import * as fs from 'fs';
let originalPath = pathHelper.getRelative('typings');
let destinationPath = pathHelper.getRelative('client', 'typings');
fs.symlink(originalPath, destinationPath, 'dir', (err) => {
if (err) return console.log(err);
console.log('Symlink successfully created!');
});
示例9: symlink
const linkDirs = (sourceDir: string, destDir: string, callback: NodeBack) => {
const type = (process.platform === 'win32') ? 'junction' : 'dir';
symlink(sourceDir, destDir, type, callback);
};