How to use the npm-packlist function in npm-packlist

To help you get started, we’ve selected a few npm-packlist 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 preconstruct / preconstruct / packages / cli / src / validate-included-files.ts View on Github external
export async function validateIncludedFiles(pkg: Package) {
  try {
    await Promise.all(
      pkg.entrypoints.map(async entrypoint => {
        let filename = path.join(
          entrypoint.directory,
          "dist",
          "preconstruct-test-file"
        );
        await fs.ensureFile(filename);
        return fs.writeFile(filename, "test content");
      })
    );

    let result = await packlist({ path: pkg.directory });

    // Ensure consistent path separators. Without this, there's a mismatch between this result and the path it
    // checks on Windows. This value will have a forward slash (dist/preconstruct-test-file), whereas the value
    // of distFilePath below will have a backslash (dist\preconstruct-test-file). Obviously these two won't match,
    // so the distfile check will fail.
    result = result.map(p => path.normalize(p));

    // check that we're including the package.json and main file
    // TODO: add Flow and TS check and if they're ignored, don't write them
    let messages: string[] = [];
    pkg.entrypoints.forEach(entrypoint => {
      let pkgJsonPath = path.relative(
        pkg.directory,
        path.resolve(entrypoint.directory, "package.json")
      );
      let distFilePath = path.relative(

npm-packlist

Get a list of the files to add from a folder into an npm package

ISC
Latest version published 4 months ago

Package Health Score

93 / 100
Full package analysis

Popular npm-packlist functions

Similar packages