How to use just-task-logger - 10 common examples

To help you get started, we’ve selected a few just-task-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 / just / packages / just-task / src / cache.ts View on Github external
for (const pkgDepInfo of dependentPkgPaths) {
    const pkgPath = pkgDepInfo.path;
    const depHashFile = path.join(pkgPath, 'node_modules/.just', CacheFileName);
    const depPackageJson = JSON.parse(fs.readFileSync(path.join(pkgPath, 'package.json'), 'utf-8'));

    if (fs.existsSync(depHashFile)) {
      const stat = fs.statSync(depHashFile);
      timestampsByPackage[pkgDepInfo.name] = stat.mtimeMs;
    } else if (depPackageJson.scripts) {
      // always updated if no hash file is found for dependants
      timestampsByPackage[pkgDepInfo.name] = new Date().getTime();
    }
  }

  logger.perf('cache:getDependentHashTimestamps');

  return timestampsByPackage;
}
github microsoft / just / packages / just-task / src / cache.ts View on Github external
function getDependentHashTimestamps() {
  mark('cache:getDependentHashTimestamps');
  const dependentPkgPaths = findDependents();

  const timestampsByPackage: { [pkgName: string]: number } = {};

  for (const pkgDepInfo of dependentPkgPaths) {
    const pkgPath = pkgDepInfo.path;
    const depHashFile = path.join(pkgPath, 'node_modules/.just', CacheFileName);
    const depPackageJson = JSON.parse(fs.readFileSync(path.join(pkgPath, 'package.json'), 'utf-8'));

    if (fs.existsSync(depHashFile)) {
      const stat = fs.statSync(depHashFile);
      timestampsByPackage[pkgDepInfo.name] = stat.mtimeMs;
    } else if (depPackageJson.scripts) {
      // always updated if no hash file is found for dependants
      timestampsByPackage[pkgDepInfo.name] = new Date().getTime();
    }
github microsoft / just / packages / just-task / src / package / findDependents.ts View on Github external
];

    return deps
      .map(dep => {
        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
        const depPackageJson = resolveCwd(path.join(dep, 'package.json'))!;

        if (!depPackageJson) {
          return null;
        }

        return { name: dep, path: path.dirname(fs.realpathSync(depPackageJson)) };
      })
      .filter(p => p && p.path.indexOf('node_modules') === -1 && isChildOf(p.path, gitRoot)) as DepInfo[];
  } catch (e) {
    logger.error(`Invalid package.json detected at ${packageJsonFile} `, e);
    return [];
  }
}
github microsoft / just / packages / create-just / src / plop.ts View on Github external
export async function runGenerator(generator: any, args: any) {
  const results = await generator.runActions(args, {
    onComment: (comment: string) => {
      logger.info(comment);
    }
  });

  if (results.failures && results.failures.length > 0) {
    throw new Error('Error: ' + results.failures[0].error);
  }

  // do something after the actions have run
  for (let change of results.changes) {
    if (change.path) {
      logger.info(change.path);
    }
  }
}
github microsoft / just / packages / just-task / src / cache.ts View on Github external
const cachePath = getCachePath();
  const cacheFile = path.join(cachePath, CacheFileName);

  if (!fs.existsSync(cacheFile)) {
    return false;
  }

  let shouldCache = false;

  try {
    const cachedHash = JSON.parse(fs.readFileSync(path.join(cachePath, CacheFileName)).toString());

    // TODO: make a more robust comparison
    shouldCache = JSON.stringify(currentHash) === JSON.stringify(cachedHash);
  } catch (e) {
    logger.warn('Invalid package-deps.json detected');
  }

  return shouldCache;
}
github microsoft / just / packages / just-task / src / cache.ts View on Github external
const packageRootPath = getPackageRootPath();

  const packageDeps = getPackageDeps(packageRootPath);

  const lockFileHashes = getLockFileHashes();

  packageDeps.files = { ...packageDeps.files, ...lockFileHashes };

  const hash = {
    args,
    taskName,
    hash: packageDeps,
    dependentHashTimestamps: getDependentHashTimestamps()
  };

  logger.perf('cache:getHash');

  return hash;
}
github microsoft / just / packages / just-task / src / package / findDependents.ts View on Github external
function collectAllDependentPaths(pkgPath: string, collected: Set = new Set()) {
  mark(`collectAllDependentPaths:${pkgPath}`);

  const depPaths = getDepsPaths(pkgPath);
  depPaths.forEach(depPath => collected.add(depPath));

  for (const depPath of depPaths) {
    if (!collected.has(depPath)) {
      collectAllDependentPaths(depPath.path, collected);
    }
  }

  logger.perf(`collectAllDependentPaths:${pkgPath}`);

  return collected;
}
github microsoft / just / packages / just-task / src / package / findDependents.ts View on Github external
export function findDependents() {
  mark('cache:findDependents');
  const results = collectAllDependentPaths(findPackageRoot());
  logger.perf('cache:findDependents');
  return results;
}
github microsoft / just / packages / just-task / src / package / findDependents.ts View on Github external
export function findDependents() {
  mark('cache:findDependents');
  const results = collectAllDependentPaths(findPackageRoot());
  logger.perf('cache:findDependents');
  return results;
}
github microsoft / just / packages / just-task / src / package / findDependents.ts View on Github external
function collectAllDependentPaths(pkgPath: string, collected: Set = new Set()) {
  mark(`collectAllDependentPaths:${pkgPath}`);

  const depPaths = getDepsPaths(pkgPath);
  depPaths.forEach(depPath => collected.add(depPath));

  for (const depPath of depPaths) {
    if (!collected.has(depPath)) {
      collectAllDependentPaths(depPath.path, collected);
    }
  }

  logger.perf(`collectAllDependentPaths:${pkgPath}`);

  return collected;
}

just-task-logger

Logger for Just scripts and tasks

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis

Similar packages