@mnrendra/rollup-plugin-chmod
v1.0.2
Published
A Rollup plugin to change file permission modes.
Downloads
16
Maintainers
Readme
@mnrendra/rollup-plugin-chmod
🍣 A Rollup plugin to change file permission modes.
Install
npm i -D @mnrendra/rollup-plugin-chmod
Usage
For ES modules (rollup.config.mjs
):
import chmod from '@mnrendra/rollup-plugin-chmod'
export default {
external: (id) => !/^[./]/.test(id),
input: 'your_input_file.(js|cjs|mjs|ts|cts|mts)',
output: {
file: 'bin/your_output_file.js',
format: 'cjs',
sourcemap: true
},
plugins: chmod({
mode: '755' // <-- Will change the 'bin/your_output_file.js' permission mode to '-rwxr-xr-x'
})
}
For CommonJS (rollup.config.js
):
const chmod = require('@mnrendra/rollup-plugin-chmod')
module.exports = {
external: (id) => !/^[./]/.test(id),
input: 'your_input_file.(js|cjs|mjs|ts|cts|mts)',
output: {
file: 'bin/your_output_file.js',
format: 'cjs',
sourcemap: true
},
plugins: chmod({
mode: '755' // <-- Will change the 'bin/your_output_file.js' permission mode to '-rwxr-xr-x'
})
}
Options
const chmod = require('@mnrendra/rollup-plugin-chmod')
module.exports = [
{
plugins: [
chmod({
/**
* The three rightmost digits define permissions for the file **owner**, **group**, and **others**.
*
* - 7: read, write, and execute
* - 6: read and write
* - 5: read and execute
* - 4: read only
* - 3: write and execute
* - 2: write only
* - 1: execute only
* - 0: no permission
*
* example, `"755"`, means:
* - The owner may read, write, and execute the file.
* - The group may read and execute the file.
* - Others may read and execute the file.
*
* @see https://nodejs.org/api/fs.html#file-modes
* */
mode: '755'
})
]
}
]
• mode
The three rightmost digits define permissions for the file owner, group, and others.
type: Mode
default: '644'
Types
import type {
Mode,
Options,
Plugin
} from '@mnrendra/rollup-plugin-chmod'