npm / npm/cli

[BUG] `npm pack` includes `.<file>.swo` and other vim editor files

Open
#4,470 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 2 Release 8.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

npm pack will include .package.json.swo (created in vim if you have multiple editors on the same file).

By default .*.swp will be ignored -- this issue is proposing adding .*.swo and possibly the entire swap space. The pattern follows the rules in findswapname. https://github.com/vim/vim/blob/master/src/memline.c#L5138 :

	/*
	 * Change the ".swp" extension to find another file that can be used.
	 * First decrement the last char: ".swo", ".swn", etc.
	 * If that still isn't enough decrement the last but one char: ".svz"
	 * Can happen when editing many "No Name" buffers.
	 */

The JS regex for names is/^\..*\.s(([a-v][a-z])|(w[a-p]))$/

Expected Behavior

The .package.json.swo file should be ignored

Steps To Reproduce
  1. touch .package.json.swo && npm pack
Environment
  • npm: 8.3.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with npm pack's ignore rules and the existing handling for .*.swp files. Compare the matcher with the Vim findswapname pattern described in the issue, then reproduce with touch .package.json.swo && npm pack; done means the .swo file and the other swap-file names covered by the stated pattern are excluded.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.