當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fs-extra.stat函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。