Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

add-dist-header

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

add-dist-header - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

dist/add-dist-header.d.ts

@@ -1,2 +0,2 @@

//! add-dist-header v0.0.2 ~ github:center-key/add-dist-header ~ MIT License
//! add-dist-header v0.0.3 ~ https://github.com/center-key/add-dist-header ~ MIT License

@@ -3,0 +3,0 @@ export declare type Options = {

@@ -1,2 +0,2 @@

//! add-dist-header v0.0.2 ~ github:center-key/add-dist-header ~ MIT License
//! add-dist-header v0.0.3 ~ https://github.com/center-key/add-dist-header ~ MIT License

@@ -20,5 +20,8 @@ import { format, parse } from 'path';

const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
const versionPattern = /{{{version}}}/g;
const versionPattern = /~~~version~~~/g;
const dist = settings.setVersion ? input.replace(versionPattern, pkg.version) : input;
const banner = `${pkg.name} v${pkg.version} ~ ${pkg.repository} ~ ${pkg.license} License`;
const info = pkg.homepage ?? pkg.repository;
const unlicensed = !pkg.license || pkg.license === 'UNLICENSED';
const license = unlicensed ? 'All Rights Reserved' : pkg.license + ' License';
const banner = `${pkg.name} v${pkg.version} ~ ${info} ~ ${license}`;
const header = (jsStyle ? '//! ' : '/*! ') + banner + (jsStyle ? '' : ' */');

@@ -25,0 +28,0 @@ const output = header + '\n\n' + dist;

{
"name": "add-dist-header",
"version": "0.0.2",
"version": "0.0.3",
"description": "Adds a header comment to a file and saves it to your distribution folder (written in TypeScript)",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -11,10 +11,15 @@ # Add Dist Header

**add-dist-header** uses the `name`, `repository`, and `license` from your
project's **package.json** file to create a header comment.
**add-dist-header** uses the `name`, `homepage`, and `license` from your
project's **package.json** file to create a header comment in a build target file.
Example header comment:
```javascript
//! my-app v0.3.7 ~ github:my-organization/my-app ~ MIT License
//! my-app v0.3.7 ~ https://github.com/my-organization/my-app ~ MIT License
```
This is particularly handy when your build tools are configured to remove comments, such as
setting `"removeComments": true` in **tsconfig.json**.
For a real-world example, check the files in the **dist** folder at
[w3c-html-validator](https://github.com/center-key/w3c-html-validator/tree/main/dist)
## 1) Setup

@@ -55,1 +60,13 @@

```
## 3) Version Number Substitution
In addition to prepending the header comment, **add-dist-header** also replaces all occurrences of
`~~~version~~~` with the version number found in the **package.json** file.
This enables inserting the current package version number into your distribution files.
The substitution feature can be disabled with the `--version` flag:
```json
"scripts": {
"add-headers": "add-dist-header --version=false build dist"
},
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc