add-dist-header
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -1,2 +0,2 @@ | ||
//! add-dist-header v0.3.0 ~~ https://github.com/center-key/add-dist-header ~~ MIT License | ||
//! add-dist-header v0.3.1 ~~ https://github.com/center-key/add-dist-header ~~ MIT License | ||
@@ -3,0 +3,0 @@ export declare type Settings = { |
@@ -1,2 +0,2 @@ | ||
//! add-dist-header v0.3.0 ~~ https://github.com/center-key/add-dist-header ~~ MIT License | ||
//! add-dist-header v0.3.1 ~~ https://github.com/center-key/add-dist-header ~~ MIT License | ||
@@ -36,6 +36,9 @@ import { format, parse } from 'path'; | ||
const type = jsStyle ? 'js' : mlStyle ? 'ml' : 'other'; | ||
const input = readFileSync(filename, 'utf-8').replace(/\r/g, ''); | ||
const out1 = settings.replaceComment ? input.replace(firstLine[type], '') : input; | ||
const input = readFileSync(filename, 'utf-8'); | ||
const normalizeEol = /\r/g; | ||
const normalizeEof = /\s*$(?!\n)/; | ||
const out1 = input.replace(normalizeEol, '').replace(normalizeEof, '\n'); | ||
const out2 = settings.replaceComment ? out1.replace(firstLine[type], '') : out1; | ||
const versionPattern = /~~~version~~~/g; | ||
const out2 = settings.setVersion ? out1.replace(versionPattern, pkg.version) : out1; | ||
const out3 = settings.setVersion ? out2.replace(versionPattern, pkg.version) : out2; | ||
const info = (_c = (_b = pkg.homepage) !== null && _b !== void 0 ? _b : pkg.docs) !== null && _c !== void 0 ? _c : pkg.repository; | ||
@@ -51,4 +54,5 @@ const unlicensed = !pkg.license || pkg.license === 'UNLICENSED'; | ||
const outputPath = slash(format({ dir: settings.dist, name: inputFile.name, ext: fileExt })); | ||
const out3 = header + spacerLines(outputPath) + out2.replace(/^\s*\n/, ''); | ||
writeFileSync(outputPath, out3); | ||
const leadingBlanks = /^\s*\n/; | ||
const final = header + spacerLines(outputPath) + out3.replace(leadingBlanks, ''); | ||
writeFileSync(outputPath, final); | ||
return { | ||
@@ -59,4 +63,4 @@ dist: distFolder, | ||
file: outputPath, | ||
length: out3.length, | ||
size: (out3.length / 1024).toLocaleString([], fixedDigits) + ' KB', | ||
length: final.length, | ||
size: (final.length / 1024).toLocaleString([], fixedDigits) + ' KB', | ||
}; | ||
@@ -63,0 +67,0 @@ }, |
{ | ||
"name": "add-dist-header", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Prepend a one-line header comment (with license notice) to distribution files", | ||
@@ -69,3 +69,3 @@ "license": "MIT", | ||
"scripts": { | ||
"step:01": "rimraf build dist spec/fixtures/dist **/.DS_Store", | ||
"step:01": "rimraf build dist spec/fixtures/target **/.DS_Store", | ||
"step:02": "jshint . --exclude-path .gitignore", | ||
@@ -72,0 +72,0 @@ "step:03": "eslint --max-warnings 0 . --ext .ts", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20371
233