本文整理汇总了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()
}
}
示例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());
}),
示例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`)
}
}
示例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,
});
});
}
});
}
示例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);
}
}
}
}
示例6: stat
export async function stat(p: string): Promise<fs.Stats | undefined> {
try {
return await fs.stat(p);
} catch (e) {
// ignore
}
}
示例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);
});
}
示例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`)
})
示例9: hasDirectory
export async function hasDirectory(dirname: string): Promise<boolean> {
try {
const stats = await fs.stat(dirname)
return stats.isDirectory()
} catch (e) {
return false
}
}
示例10: fileExists
export async function fileExists(fileName: string): Promise<boolean> {
try {
const stat = await fs.stat(fileName);
return stat.isFile();
} catch {
return false;
}
}