Skip to content

Commit a34589b

Browse files
committed
remove time from patch header
patch files should be timeless by default versioning is done by git
1 parent ad88c72 commit a34589b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/makePatch.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ export function makePatch({
9797
})
9898

9999
function cleanup() {
100+
if (isDebug) {
101+
console.log(`patch-package/makePatch: cleanup: keeping temporary files: ${tmpRepo.name}`)
102+
return
103+
}
100104
tmpRepo.removeCallback()
101105
}
102106

@@ -195,13 +199,14 @@ commitHash is the full hash with 40 chars.`)
195199
}
196200
}
197201
// https://docs.npmjs.com/about-semantic-versioning
198-
if (!v.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)) {
199-
var exactPart = v.match(/^[^~]([0-9]+\.[0-9]+\.[0-9]+)$/)
200-
var exampleVersion = '1.2.3'
201-
if (exactPart) {
202-
exampleVersion = exactPart[1]
202+
// TODO handle protocols? pnpm workspace: protocol does not make sense here, no need to patch local packages
203+
var m = v.match(/^([~^])(.*)$/)
204+
if (m) {
205+
var exampleVersion = m[1]
206+
if (!exampleVersion) {
207+
exampleVersion = '1.0.0'
203208
}
204-
console.warn(`patch-package/makePatch: warning: found wildcard version. \
209+
console.warn(`patch-package/makePatch: warning: found wildcard version ${v}. \
205210
to ensure successful patching, package.json should pin the exact version of ${packageDetails.name} \
206211
in the format <major>.<minor>.<patch>, for example: "${packageDetails.name}": "${exampleVersion}"`)
207212
}
@@ -473,11 +478,7 @@ in the format <major>.<minor>.<patch>, for example: "${packageDetails.name}": "$
473478
// patchfiles are parsed in patch/parse.ts function parsePatchLines
474479
// -> header comments are ignored
475480
let diffHeader = ""
476-
const dateStr = (
477-
isTest ? '1980-01-01 00:00:00' : // mock date
478-
new Date().toLocaleString("lt")
479-
)
480-
diffHeader += `# generated by patch-package ${patchPackageVersion} on ${dateStr}\n`
481+
diffHeader += `# generated by patch-package ${patchPackageVersion}\n`
481482
diffHeader += `#\n`
482483
const prettyArgv = process.argv.slice()
483484
if (prettyArgv[0].match(/node/)) {

0 commit comments

Comments
 (0)