# gulp-chmod

> Change permissions of Vinyl files

Latest version **4.0.0** (published 2023-10-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-chmod
pnpm add gulp-chmod
yarn add gulp-chmod
bun add gulp-chmod
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2023-10-31 |
| First published | 2014-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 3 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 39 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | gulpplugin, chmod, stat, file, vinyl, stream, permissions |

## Links

- npm: https://www.npmjs.com/package/gulp-chmod
- Repository: https://github.com/sindresorhus/gulp-chmod
- Homepage: https://github.com/sindresorhus/gulp-chmod#readme
- Issues: https://github.com/sindresorhus/gulp-chmod/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/gulp-chmod

## Dependencies (3)

- [stat-mode](https://npm.io/package/stat-mode.md) ^1.0.0
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2
- [gulp-plugin-extras](https://npm.io/package/gulp-plugin-extras.md) ^0.2.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 4.0.0 (latest) — 2023-10-31
- 3.1.0 — 2023-07-05
- 3.0.0 — 2019-05-28
- 2.0.0 — 2016-11-08
- 1.3.0 — 2015-10-16
- 1.2.0 — 2014-10-22
- 1.1.1 — 2014-09-02
- 1.1.0 — 2014-08-07
- 1.0.0 — 2014-07-26
- 0.2.2 — 2014-07-26
- 0.2.1 — 2014-06-10
- 0.2.0 — 2014-03-07
- 0.1.0 — 2014-03-07

## README

# gulp-chmod

> [Change permissions](https://en.wikipedia.org/wiki/Chmod) of [Vinyl](https://github.com/gulpjs/vinyl) files

## Install

```sh
npm install --save-dev gulp-chmod
```

## Usage

```js
import gulp from 'gulp';
import chmod from 'gulp-chmod';

export default () => (
	gulp.src('src/app.js')
		.pipe(chmod(0o755))
		.pipe(gulp.dest('dist'))
);
```

or

```js
import gulp from 'gulp';
import chmod from 'gulp-chmod';

export default () => (
	gulp.src('src/app.js')
		.pipe(chmod({
			owner: {
				read: true,
				write: true,
				execute: true
			},
			group: {
				execute: true
			},
			others: {
				execute: true
			}
		}))
		.pipe(gulp.dest('dist'))
);
```

## API

### chmod(fileMode, directoryMode?)

#### fileMode

Type: `number | object`

Can either be a [chmod](https://ss64.com/bash/chmod.html) octal number or an object with the individual permissions specified.

Values depends on the current file, but these are the possible keys:

```js
{
	owner: {
		read: true,
		write: true,
		execute: true
	},
	group: {
		read: true,
		write: true,
		execute: true
	},
	others: {
		read: true,
		write: true,
		execute: true
	}
}
```

When `read`, `write`, and `execute` are the same, you can simplify the object:

```js
{
	read: true
}
```

Pass `undefined` to not set permissions on files. Useful if you only want to set permissions on directories.

#### directoryMode

Type: `true | number | object`

Same as `fileMode`, but applies to directories.

Specify `true` to use the same value as `fileMode`.

## Tip

Combine it with [gulp-filter](https://github.com/sindresorhus/gulp-filter) to only change permissions on a subset of the files.

```js
import gulp from 'gulp';
import chmod from 'gulp-chmod';
import gulpFilter from 'gulp-filter';

const filter = gulpFilter('src/cli.js', {restore: true});

export default = () => (
	gulp.src('src/*.js')
		// Filter a subset of the files
		.pipe(filter)
		// Make them executable
		.pipe(chmod(0o755))
		// Bring back the previously filtered out files
		.pipe(filter.restore)
		.pipe(gulp.dest('dist'))
);
```

## Related

- [gulp-chown](https://github.com/sindresorhus/gulp-chown) - Change owner of Vinyl files

---
_Source: https://npm.io/package/gulp-chmod · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
