本文整理汇总了TypeScript中fs.realpathSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript realpathSync函数的具体用法?TypeScript realpathSync怎么用?TypeScript realpathSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了realpathSync函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getNodeSystem
//.........这里部分代码省略.........
args: process.argv.slice(2),
newLine: _os.EOL,
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
write(s: string): void {
process.stdout.write(s);
},
readFile,
writeFile,
watchFile: (fileName, callback) => {
if (useNonPollingWatchers) {
const watchedFile = watchedFileSet.addFile(fileName, callback);
return {
close: () => watchedFileSet.removeFile(watchedFile)
};
}
else {
_fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);
return {
close: () => _fs.unwatchFile(fileName, fileChanged)
};
}
function fileChanged(curr: any, prev: any) {
if (+curr.mtime <= +prev.mtime) {
return;
}
callback(fileName);
}
},
watchDirectory: (directoryName, callback, recursive) => {
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
let options: any;
if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) {
options = { persistent: true, recursive: !!recursive };
}
else {
options = { persistent: true };
}
return _fs.watch(
directoryName,
options,
(eventName: string, relativeFileName: string) => {
// In watchDirectory we only care about adding and removing files (when event name is
// "rename"); changes made within files are handled by corresponding fileWatchers (when
// event name is "change")
if (eventName === "rename") {
// When deleting a file, the passed baseFileName is null
callback(!relativeFileName ? relativeFileName : normalizePath(combinePaths(directoryName, relativeFileName)));
};
}
);
},
resolvePath: function (path: string): string {
return _path.resolve(path);
},
fileExists,
directoryExists,
createDirectory(directoryName: string) {
if (!this.directoryExists(directoryName)) {
_fs.mkdirSync(directoryName);
}
},
getExecutingFilePath() {
return __filename;
},
getCurrentDirectory() {
return process.cwd();
},
getDirectories,
readDirectory,
getModifiedTime(path) {
try {
return _fs.statSync(path).mtime;
}
catch (e) {
return undefined;
}
},
createHash(data) {
const hash = _crypto.createHash("md5");
hash.update(data);
return hash.digest("hex");
},
getMemoryUsage() {
if (global.gc) {
global.gc();
}
return process.memoryUsage().heapUsed;
},
exit(exitCode?: number): void {
process.exit(exitCode);
},
realpath(path: string): string {
return _fs.realpathSync(path);
}
};
}
开发者ID:om3r,项目名称:typescript-closure-compiler-1.8,代码行数:101,代码来源:sys.ts
示例2:
.find((d) => path.join(root, "packages", d) === fs.realpathSync(path.join(root, "packages", d)))
开发者ID:DanTup,项目名称:Dart-Code,代码行数:1,代码来源:utils.ts
示例3: checkPath
private checkPath(path: string) {
if (!fs.realpathSync(path).startsWith(fs.realpathSync(this.repoRoot))) {
throw new Error('invalid path');
}
}
开发者ID:elastic,项目名称:kibana,代码行数:5,代码来源:git_operations.ts
示例4: if
import * as path from 'path'
import resolve from 'resolve'
const ensureSlash = (filepath: any, needsSlash: boolean) => {
const hasSlash = filepath.endsWith('/')
if (hasSlash && !needsSlash) {
return filepath.substr(filepath, filepath.length - 1)
} else if (!hasSlash && needsSlash) {
return `${filepath}/`
} else {
return filepath
}
}
export const root = fs.realpathSync(process.cwd())
const resolveApp = (to: string) => path.resolve(root, to)
export interface Paths {
root: string
templates: string
packageJson: string
servedPath: (base: string) => string
docz: string
app: string
getDist: (dest: string) => string
distPublic: (dest: string) => string
importsJs: string
rootJs: string
indexJs: string
indexHtml: string
开发者ID:leslieSie,项目名称:docz,代码行数:31,代码来源:paths.ts
示例5:
{
let s = '123';
let b: Buffer;
fs.realpath('/path/to/folder', (err, resolvedPath) => s = resolvedPath);
fs.realpath('/path/to/folder', undefined, (err, resolvedPath) => s = resolvedPath);
fs.realpath('/path/to/folder', 'utf8', (err, resolvedPath) => s = resolvedPath);
fs.realpath('/path/to/folder', 'buffer', (err, resolvedPath) => b = resolvedPath);
fs.realpath('/path/to/folder', s, (err, resolvedPath) => typeof resolvedPath === 'string' ? s = resolvedPath : b = resolvedPath);
fs.realpath('/path/to/folder', {}, (err, resolvedPath) => s = resolvedPath);
fs.realpath('/path/to/folder', { encoding: undefined }, (err, resolvedPath) => s = resolvedPath);
fs.realpath('/path/to/folder', { encoding: 'utf8' }, (err, resolvedPath) => s = resolvedPath);
fs.realpath('/path/to/folder', { encoding: 'buffer' }, (err, resolvedPath) => b = resolvedPath);
fs.realpath('/path/to/folder', { encoding: s }, (err, resolvedPath) => typeof resolvedPath === "string" ? s = resolvedPath : b = resolvedPath);
s = fs.realpathSync('/path/to/folder');
s = fs.realpathSync('/path/to/folder', undefined);
s = fs.realpathSync('/path/to/folder', 'utf8');
b = fs.realpathSync('/path/to/folder', 'buffer');
const v1 = fs.realpathSync('/path/to/folder', s);
typeof v1 === "string" ? s = v1 : b = v1;
s = fs.realpathSync('/path/to/folder', {});
s = fs.realpathSync('/path/to/folder', { encoding: undefined });
s = fs.realpathSync('/path/to/folder', { encoding: 'utf8' });
b = fs.realpathSync('/path/to/folder', { encoding: 'buffer' });
const v2 = fs.realpathSync('/path/to/folder', { encoding: s });
typeof v2 === "string" ? s = v2 : b = v2;
// native
fs.realpath.native('/path/to/folder', (err, resolvedPath) => s = resolvedPath);
开发者ID:ChaosinaCan,项目名称:DefinitelyTyped,代码行数:30,代码来源:node-tests.ts
示例6:
filePaths.map((filePath: string): string => fs.realpathSync(filePath)));
开发者ID:dufrannea,项目名称:TSLint.MSBuild,代码行数:1,代码来源:LintRunner.ts
示例7: comparePath
function comparePath(pathA: string, pathB: string) {
const pa = fs.realpathSync(pathA);
const pb = fs.realpathSync(pathB);
return path.resolve(pa) === path.resolve(pb);
}
开发者ID:elastic,项目名称:kibana,代码行数:5,代码来源:lsp_service.ts
注:本文中的fs.realpathSync函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论