How to use the backfill-logger.logger.profile function in backfill-logger

To help you get started, we’ve selected a few backfill-logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / backfill / packages / backfill / src / hasher.ts View on Github external
const hashOfBuildCommand = createHash(this.buildCommandSignature).then(
      hash => {
        logger.verbose(`hashOfBuildCommand: ${hash}`);
        return hash;
      }
    );
    const hashOfOwnFiles = this.getHashOfOwnFiles().then(hash => {
      logger.verbose(`hashOfOwnFiles: ${hash}`);
      return hash;
    });
    const hashOfLockFile = this.getHashOfLockFile().then(hash => {
      logger.verbose(`hashOfLockFile: ${hash}`);
      return hash;
    });

    logger.profile("hasher:calculateHash");

    // 1. Create hash to be used when fetching cache from cache storage
    const packageHash = await Promise.all([
      ...hashOfDependencies,
      hashOfBuildCommand,
      hashOfOwnFiles,
      hashOfLockFile
    ])
      .then(hashes => hashes.filter(notEmpty))
      .then(hashes => createHash(hashes));

    logger.profile("hasher:calculateHash");

    // 2. Create hash to be stored in the package. Used to communicate the state
    // of the package to dependent packages (parents)
    await Promise.all([...hashOfDependencies, hashOfOwnFiles, hashOfLockFile])
github microsoft / backfill / packages / backfill / src / commandRunner.ts View on Github external
return async (): Promise => {
    const parsedBuildCommand = buildCommand.join(" ");

    if (!parsedBuildCommand) {
      throw new Error("Command not provided");
    }

    // Clear outputFolder to guarantee a deterministic cache
    if (clearOutputFolder) {
      await Promise.all(
        outputFolderAsArray(outputFolder).map(folder => fs.remove(folder))
      );
    }

    // Set up runner
    logger.profile("buildCommand:run");
    const runner = execa(parsedBuildCommand, {
      shell: true,
      ...(process.env.NODE_ENV !== "test" ? { stdio: "inherit" } : {})
    });

    return (
      runner
        // Add build time to the performance logger
        .then(() => {
          logger.setTime("buildTime", "buildCommand:run");
        })
        // Catch to pretty-print the command that failed and re-throw
        .catch(err => {
          if (process.env.NODE_ENV !== "test") {
            logger.error(`Failed while running: "${parsedBuildCommand}"`);
          }
github microsoft / backfill / packages / hasher / src / index.ts View on Github external
public async createPackageHash(): Promise {
    logger.profile("hasher:calculateHash");

    const packageRoot = await getPackageRoot(this.packageRoot);
    const yarnLock = await parseLockFile(packageRoot);
    const workspaces = getYarnWorkspaces(packageRoot);

    const queue = [packageRoot];
    const done: PackageHashInfo[] = [];

    while (queue.length > 0) {
      const packageRoot = queue.shift();

      if (!packageRoot) {
        continue;
      }

      const packageHash = await getPackageHash(