本文整理汇总了TypeScript中fs-extra.stat函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stat函数的具体用法?TypeScript stat怎么用?TypeScript stat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stat函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: determineConfigFilename
export async function determineConfigFilename(
cmdLineArgs: CliArgTypes
): Promise<string> {
if (cmdLineArgs.config == null) {
try {
await fs.stat('text-run.yml')
return 'text-run.yml'
} catch (e) {
return ''
}
}
// TODO: move this to the top of the method
try {
await fs.stat(cmdLineArgs.config)
return cmdLineArgs.config
} catch (e) {
console.log(
chalk.red(
`configuration file ${chalk.cyan(cmdLineArgs.config)} not found`
)
)
throw new PrintedUserError()
}
}
开发者ID:Originate,项目名称:tutorial-runner,代码行数:25,代码来源:determine-config-filename.ts
示例2: withAfterEach
withAfterEach(async t => {
shell.cd('test/assets');
shell.ln('-s', 'foo.txt', 'bar.txt');
shell.cd('../..');
const { stderr } = shell.exec('node dist/src/cp-cli -d test/assets out');
t.equal(stderr, '');
let stats = await fse.stat('out/foo.txt');
t.true(stats.isFile());
stats = await fse.stat('out/bar.txt');
t.true(stats.isFile());
t.false(stats.isSymbolicLink());
}),
开发者ID:screendriver,项目名称:cp-cli,代码行数:12,代码来源:cp-cli.test.ts
示例3: checkLocalImage
async function checkLocalImage(imagePath: string, c: Configuration) {
try {
await fs.stat(path.join(c.sourceDir, imagePath))
} catch (err) {
throw new Error(`image ${chalk.red(imagePath)} does not exist`)
}
}
开发者ID:Originate,项目名称:tutorial-runner,代码行数:7,代码来源:check-image.ts
示例4: buildInlineLambda
export function buildInlineLambda({
path: inputPath,
name,
options,
parameters,
}: any) {
name = name ? name : defaultConfig.FunctionName;
options = options ? merge({}, defaultConfig, options) : defaultConfig;
inputPath = resolve(inputPath);
return stat(inputPath).then(rstat => {
if (rstat.isFile()) {
return _createInlineFunction({
name,
options,
parameters,
path: inputPath,
});
} else {
const indexPath = resolve(inputPath, 'index.js');
return stat(indexPath).then(statIndex => {
return _createInlineFunction({
name,
options,
parameters,
path: indexPath,
});
});
}
});
}
开发者ID:arminhammer,项目名称:wolkenkratzer,代码行数:30,代码来源:lambda.macro.ts
示例5: clearNodeModules
async function clearNodeModules(): Promise<void> {
const logger = getLogger();
if (isRsyncModeEnabled) {
return;
}
logger.trace(`moving node_modules to node_modules.bak.0`);
let bodyCount = 0;
let bakDirname;
while (true) {
bakDirname = `${nodeModules}.bak.${bodyCount}`;
logger.trace(`moving node_modules to ${bakDirname}`);
try {
await fsExtra.stat(bakDirname);
logger.trace(`${bakDirname} already exists; incrementing`);
bodyCount++;
} catch (err) {
if (err.code && err.code === 'ENOENT') {
await fsExtra.rename(nodeModules, bakDirname);
logger.trace(`move was successful; removing ${bakDirname} without blocking`);
return fsExtra.remove(bakDirname);
}
}
}
}
开发者ID:mutantcornholio,项目名称:veendor,代码行数:26,代码来源:index.ts
示例6: stat
export async function stat(p: string): Promise<fs.Stats | undefined> {
try {
return await fs.stat(p);
} catch (e) {
// ignore
}
}
开发者ID:driftyco,项目名称:ionic-cli,代码行数:7,代码来源:safe.ts
示例7: remove
export function remove(path: string, callback: (err?: Error) => void) {
fs.stat(path, function (err, stats) {
if (err) {
return callback(err);
}
fs.remove(path, callback);
});
}
开发者ID:zaggino,项目名称:brackets-electron,代码行数:8,代码来源:fs-additions.ts
示例8: Then
Then('there is no {string} folder', async function(name) {
try {
await fs.stat(path.join(this.rootDir, name))
} catch (e) {
return
}
throw new Error(`Expected folder ${name} to not be there, but it is`)
})
开发者ID:Originate,项目名称:tutorial-runner,代码行数:8,代码来源:then-steps.ts
示例9: hasDirectory
export async function hasDirectory(dirname: string): Promise<boolean> {
try {
const stats = await fs.stat(dirname)
return stats.isDirectory()
} catch (e) {
return false
}
}
开发者ID:Originate,项目名称:tutorial-runner,代码行数:8,代码来源:has-directory.ts
示例10: fileExists
export async function fileExists(fileName: string): Promise<boolean> {
try {
const stat = await fs.stat(fileName);
return stat.isFile();
} catch {
return false;
}
}
开发者ID:codeandcats,项目名称:Polygen,代码行数:8,代码来源:fileSystem.ts
注:本文中的fs-extra.stat函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论