@gerhobbelt/prepend-header
v1.1.0-8
Published
Use a JS module to define a header to prepend to one or more files.
Downloads
93
Readme
Prepend text to a file / group of files
Example(s):
prepend-header src/foo.js 'header.config.js' (single file)
prepend-header src/**/*.js 'header.config.js' (all files matching glob)
.
Successful Output should look like:
[FILES from src/**/*]
Prepended to src/after1.js
Prepended to src/foo/after2.js
Prepended to src/foo/after3.js
Local Project:
npm i prepend-header --save-dev
- create a
header.config.js
in your root that looks something like:
const year = new Date().getFullYear();
const text = `/*******************************************************************************
* Licensed Materials - Property of IBM
* (c) Copyright IBM Corporation ${year}. All Rights Reserved.
*
* Note to U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule
* Contract with IBM Corp.
*******************************************************************************/
`;
const match = 'Reserved'; // avoid double-prepends. if this word exists in a file, that file gets skipped.
module.exports = {
text,
match,
};
- In package.json do:
"scripts" {
"prepend-header": "prepend-header src/**/*.js header.config.js",
}
npm run prepend-header
Run with npx
- create a header.config.js in your current working directory see above for format)
npx prepend-header src/**/*.js header.config.js
Releasing
- npm version patch
- npm publish
- git push --tags
- create GH release