Np: Ensure that required files are packaged

Created on 17 Aug 2016  路  5Comments  路  Source: sindresorhus/np

I just published a package with the wrong files and bin package.json settings. I'm surprised that npm doesn't check this at all since an incorrect bin causes a subsequent install to fail.

Possible checks:

  • files listed in files exist
  • files listed in bin exist
  • walk the dependency tree starting from main to make sure that all non-external requires are included in files or not npmignored
enhancement help wanted

All 5 comments

files listed in files exist
files listed in bin exist

Good idea! For files, we can do it as long as it's not a glob pattern, which is allowed.

walk the dependency tree starting from main to make sure that all non-external requires are included in files or not npmignored

We talked about it previously, but it's very complicated, especially when you start having Babel and Webpack in the picture. I think we instead should get it implemented in eslint-plugin-import and recommend that.

// @benmosher @jfmengels

eslint-plugin-node has no-unpublished-requires. I'd be up for something similiar in eslint-plugin-import but what's there in the node plugin might work as-is? (though I don't know if that plugin handles ES6 modules, I'd believe it doesn't)

@bfred-it Would you mind reposting your https://github.com/npm/npm/issues/13948 proposal on the Yarn issue tracker? I don't see it going anywhere with the npm client.

npm exposes a useful method: require('npm/libs/pack').getContents()

From this I think it's a matter of testing pkg.bin in getContents() and such

Here: https://github.com/typicode/pkg-ok

Apparently it's pretty old, even

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikehardy picture mikehardy  路  6Comments

sindresorhus picture sindresorhus  路  4Comments

ProfessorManhattan picture ProfessorManhattan  路  4Comments

janpio picture janpio  路  6Comments

bennycode picture bennycode  路  4Comments