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( entrypoint => {
        let filename = path.join(
        await fs.ensureFile(filename);
        return fs.writeFile(filename, "test content");

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

    // 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 = => 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(,
        path.resolve(, "package.json")
      let distFilePath = path.relative(


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

Latest version published 3 months ago

Package Health Score

91 / 100
Full package analysis

Popular npm-packlist functions

Similar packages