How to use the @ionic/utils-fs.getFileChecksum function in @ionic/utils-fs

To help you get started, we’ve selected a few @ionic/utils-fs 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 ionic-team / starters / src / commands / find-redundant.ts View on Github external
for (const starterDir of starterDirs) {
        const [ , starterType ] = getStarterInfoFromPath(starterDir);
        const id = buildStarterId(ionicType, starterType, starterDir);

        const contents = (await readdirp(starterDir)).map(p => p.substring(starterDir.length + 1));

        for (const file of contents) {
          const filePath = path.resolve(starterDir, file);
          const baseFilePath = path.resolve(baseDir, file);

          try {
            const [ fileStat, baseFileStat ] = await Promise.all([stat(filePath), stat(baseFilePath)]);

            if (!fileStat.isDirectory() && !baseFileStat.isDirectory()) {
              const [ fileChecksum, baseFileChecksum ] = await Promise.all([getFileChecksum(filePath), getFileChecksum(baseFilePath)]);

              if (fileChecksum === baseFileChecksum) {
                log(id, chalk.red(`${chalk.bold(file)}: same file in base files`));
                redundantFiles.push(filePath);
              } else {
                log(id, chalk.gray(`${chalk.bold(file)}: found in base files, but checksum differs`));
              }
            }
          } catch (e) {
            // ignore
          }
        }
      }
    }

    if (redundantFiles.length > 0) {