Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm pack excludes files with character * in the path #3722

Closed
1 task done
uladkasach opened this issue Sep 6, 2021 · 3 comments
Closed
1 task done

[BUG] npm pack excludes files with character * in the path #3722

uladkasach opened this issue Sep 6, 2021 · 3 comments
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@uladkasach
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

npm pack does not include files with paths containing the character * in the package (i.e., it excludes them)

for example, if you have a directory with the following structure:

- src
  - fileA.js
  - *.fileB.js
  - directoryA
    - fileC.js
    - *.fileD.js
  - **
    - fileE.js
    - *.fileF.js

npm pack will only include the following files

- src
  - fileA.js
  - directoryA
    - fileC.js

that is, it will exclude src/*.fileD.js, src/directoryA/*.fileD.js, src/**/fileE.js, and src/**/*.fileF.js

Expected Behavior

npm pack should include files with path names containing the character * in the package unless explicitly requested to be excluded (or at the least, it should be possible to explicitly include those files).

for example, if you have a directory with the following structure:

- src
  - fileA.js
  - *.fileB.js
  - directoryA
    - fileC.js
    - *.fileD.js
  - **
    - fileE.js
    - *.fileF.js

npm pack should include all of those files in the created package

Steps To Reproduce

  1. Create a new directory for this package
mkdir -p ~/git/tmp/package-with-wildcard-chars-in-paths;
cd ~/git/tmp/package-with-wildcard-chars-in-paths;
  1. provision the files listed in the current behavior example
cd ~/git/tmp/package-with-wildcard-chars-in-paths;
mkdir src;
echo "module.exports = 'placeholder'" >> 'src/fileA.js';
echo "module.exports = 'placeholder'" >> 'src/*.fileB.js';
mkdir 'src/directoryA';
echo "module.exports = 'placeholder'" >> 'src/directoryA/fileC.js';
echo "module.exports = 'placeholder'" >> 'src/directoryA/*.fileD.js';
mkdir 'src/**';
echo "module.exports = 'placeholder'" >> 'src/**/fileE.js';
echo "module.exports = 'placeholder'" >> 'src/**/*.fileF.js';
  1. Create an package.json
echo '{ "name": "test-package", "version":"0.0.1" }' >> 'package.json';
  1. Run npm pack

  2. See that only the files without character * in their paths were included

git/tmp/package-with-wildcard-chars-in-paths is v0.0.1 via ⬢ v16.8.0 at 12:48:21 
➜ npm pack  
npm notice 
npm notice 📦  [email protected]
npm notice === Tarball Contents === 
npm notice 46B  package.json           
npm notice 31B  src/directoryA/fileC.js
npm notice 31B  src/fileA.js           
npm notice 237B test-package-0.0.1.tgz 
npm notice === Tarball Details === 
npm notice name:          test-package                            
npm notice version:       0.0.1                                   
npm notice filename:      test-package-0.0.1.tgz                  
npm notice package size:  513 B                                   
npm notice unpacked size: 345 B                                   
npm notice shasum:        c8bc32ae1524862b9aa943d8a189707562196881
npm notice integrity:     sha512-anN6bM/h2587w[...]AWT/lJioUazBQ==
npm notice total files:   4                                       
npm notice 
test-package-0.0.1.tgz

Environment

  • OS: Ubuntu 21.04
  • Node: ⬢ v16.8.0
  • npm: 7.21.0
@uladkasach uladkasach added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Sep 6, 2021
@uladkasach uladkasach changed the title [BUG] npm pack excludes and files with charcter * in the path [BUG] npm pack excludes files with character * in the path Sep 6, 2021
@lukekarrys lukekarrys added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Sep 24, 2021
@DanielRuf
Copy link

The * makes not much sense in file names and folder names. There is a rule for many years in one of the npm depemdencies which prevents this. * is normally a glob parameter.

@DanielRuf
Copy link

See https://github.com/npm/npm-packlist/blob/main/index.js#L65

const nameIsBadForWindows = file => /*/.test(file)

Relevant commit: npm/npm-packlist@6655e3c#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346

Relevant issue: npm/npm-packlist#9

Suggested solution: rename the files

@uladkasach
Copy link
Author

Ah, I see. Bummer.

Thank you for tracking those references down.

No *'s in file names it is 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

3 participants