Skip to content

Commit

Permalink
Check packed files for files suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Oct 9, 2023
1 parent d47b807 commit 167453a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ export async function publint({ pkgDir, vfs, level, strict, _packedFiles }) {
promiseQueue.push(async () => {
for (const p of commonInternalPaths) {
const internalPath = vfs.pathJoin(pkgDir, p)
if (
_packedFiles &&
_packedFiles.every((f) => !f.startsWith(internalPath))
) {
continue
}
if (await vfs.isPathExist(internalPath)) {
messages.push({
code: 'USE_FILES',
Expand Down
1 change: 1 addition & 0 deletions pkg/tests/fixtures/npmignore/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests
1 change: 1 addition & 0 deletions pkg/tests/fixtures/npmignore/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = 'This file is ESM, but extension says CJS'
7 changes: 7 additions & 0 deletions pkg/tests/fixtures/npmignore/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "publint-npmignore",
"version": "0.0.1",
"private": true,
"type": "module",
"exports": "./main.js"
}
1 change: 1 addition & 0 deletions pkg/tests/fixtures/npmignore/tests/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// suggest pkg.files if this file is published
2 changes: 2 additions & 0 deletions pkg/tests/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ testFixture('exports-module', ['EXPORTS_MODULE_SHOULD_PRECEDE_REQUIRE'])

testFixture('publish-config', ['FILE_DOES_NOT_EXIST', 'USE_EXPORTS_BROWSER'])

testFixture('npmignore', [])

testFixture('test-1', [
'FILE_INVALID_FORMAT',
'TYPES_NOT_EXPORTED',
Expand Down

0 comments on commit 167453a

Please sign in to comment.