How to use the @ts-common/azure-js-dev-tools.normalize function in @ts-common/azure-js-dev-tools

To help you get started, we’ve selected a few @ts-common/azure-js-dev-tools 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 Azure / azure-sdk-for-js / gulpfile.ts View on Github external
shouldPack = true;
          } else if (toPack === PackagesToPack.DifferentVersion) {
            let npmPackageVersion: string | undefined;
            try {
              const npmViewResult: NPMViewResult = npm.view({ packageName, ...runOptions, showCommand: false, showOutput: false });
              const distTags: StringMap | undefined = npmViewResult["dist-tags"];
              npmPackageVersion = distTags && distTags["latest"];
            }
            catch (error) {
              // This happens if the package doesn't exist in NPM.
            }

            _logger.logTrace(`Local version: ${localPackageVersion}, NPM version: ${npmPackageVersion}`);
            shouldPack = localPackageVersion !== npmPackageVersion;
          } else if (toPack === PackagesToPack.BranchHasChanges) {
            const packageFolderPathWithSep: string = normalize(packageFolderPath + path.posix.sep);
            shouldPack = !!changedFiles && contains(changedFiles, (changedFilePath: string) => normalize(changedFilePath).startsWith(packageFolderPathWithSep));
          }

          if (!shouldPack) {
            upToDatePackages++;
          } else {
            _logger.log(`Packing package "${packageName}" with version "${localPackageVersion}"...${args.whatif ? " (SKIPPED)" : ""}`);
            if (!args.whatif) {
              try {
                npm.pack(runOptions);
                const packFileName = `${packageName.replace("/", "-").replace("@", "")}-${localPackageVersion}.tgz`
                const packFilePath = path.join(packageFolderPath, packFileName);
                fs.renameSync(packFilePath, path.join(dropFolderPath, packFileName));
                _logger.log(`Filename: ${packFileName}`);
                packedPackages++;
              }
github Azure / azure-sdk-for-js / .scripts / checkEverything.ts View on Github external
logger.logVerbose(changedFilePath);
    }
  }
}

const repositoryFolderPath: string = resolvePath(__dirname, "..");
const packagesFolderPath: string = joinPath(repositoryFolderPath, "sdk");
const packageFolderPaths: string[] | undefined = getPackageFolderPaths(packagesFolderPath);

let exitCode: number = 0;
if (!packageFolderPaths) {
  logger.logError(`The packages folder (${packagesFolderPath}) doesn't exist.`);
} else {
  logger.logVerbose(`Found ${packageFolderPaths.length} package folders.`);
  for (const packageFolderPath of packageFolderPaths) {
    const packageFolderPathWithSep: string = normalize(packageFolderPath + path.posix.sep);
    const shouldCheck = !!changedFiles && contains(changedFiles, (changedFilePath: string) => normalize(changedFilePath).startsWith(packageFolderPathWithSep));
    if (shouldCheck) {
      exitCode += checkEverything({
        logger,
        checkPackageJsonVersionOptions: {
          startPath: packageFolderPath
        },
        checkForOnlyCallsOptions: {
          startPaths: packageFolderPath
        },
        checkForSkipCallsOptions: {
          startPaths: packageFolderPath
        }
      });
    }
  }