1.1.0 • Published 2 years ago

prepend-directive v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

prepend-directive

Prepend a directive to the top of a file.

Useful as a post build script if your build tool (e.g. microbundle) strips comments and does not allow you to configure the behavior conditionally.

CLI interface

npx prepend-directive@latest --directive=\"use strict\" --files=file-a.js,file-b.js

Node CJS interface

const prependDirective = require(`prepend-directive`);

prependDirective({
  directive: `use strict`,
  files: [`file-a.js`, `file-b.js`],
  cwd: __dirname, // Optional
});

Before

file-a.js:

const a = () => `a`;

file-b.js:

const b = () => `b`;

After

file-a.js:

"use strict"
const a = () => `a`;

file-b.js:

"use strict"
const b = () => `b`;
1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago