# grunt-setmymode

> finds all files and directories under a given directory, and sets their permissions if owned by executing user

Latest version **0.3.2** (published 2014-06-06) · 0 weekly downloads

## Install

```sh
npm install grunt-setmymode
pnpm add grunt-setmymode
yarn add grunt-setmymode
bun add grunt-setmymode
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2014-06-06 |
| First published | 2014-03-24 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nicholas Shewmaker |
| Maintainers | nshewmaker |
| Keywords | gruntplugin |

## Links

- npm: https://www.npmjs.com/package/grunt-setmymode
- Repository: https://github.com/NShewmaker/grunt-setmymode
- Issues: https://github.com/NShewmaker/grunt-setmymode/issues
- npm.io page: https://npm.io/package/grunt-setmymode

## Dependencies (1)

- [glob](https://npm.io/package/glob.md) ~3.2.9

## Recent versions

- 0.3.2 (latest) — 2014-06-06
- 0.3.1 — 2014-06-06
- 0.2.1 — 2014-03-26
- 0.2.0 — 2014-03-26
- 0.1.3 — 2014-03-25
- 0.1.2 — 2014-03-25
- 0.1.1 — 2014-03-24
- 0.1.0 — 2014-03-24

## README

# grunt-setmymode

> finds all files and directories under a given directory, and sets their permissions if owned by executing user

## Why?

I work with several teammates on a shared development web server. As we deploy our code, it is important that we
can write to directories others have created and can overwrite files that the others may have installed. The
"mode" option of grunt-contrib-copy is insufficient for two main reasons:
   1. files and directories typically need different modes (see [enhancement #152](https://github.com/gruntjs/grunt-contrib-copy/issues/152))
   2. a `chmod` is attempted regardless of need. This fails on files that the current user doesn't own.

This plugin addresses both issues. It allows you to specify a mode each for files and directories,
and will only `chmod` on files the current user owns (the "my" in the plugin name), and only
when the mode isn't already at the given setting.

## Getting Started
This plugin requires Grunt `~0.4.4`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-setmymode --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-setmymode');
```

## The "setmymode" task

### Overview
In your project's Gruntfile, add a section named `setmymode` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
  setmymode: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});
```

### Options

#### options.directory
Type: `String`
Default value: none

All files and directories under, and including, `directory` will have the appropriate mode applied.

#### options.files
Type: `Array`
Default value: none

Additional, individual files to which the given mode will be applied.

#### options.modeDirs
Type: `String`
Default value: `2771`

the octal mode setting for directories

#### options.modeDirs
Type: `String`
Default value: `0664`

the octal mode setting for files

### Usage Examples

#### Default Options
In this example, the default options are used to set permissions on the `/var/www/myclient` web server directory.

```js
grunt.initConfig({
  setmymode: {
    options: {
      directory: "/var/www/myclient"
    },
    main: {}
  },
});
```

#### Custom Options
In this example, custom options are used to set permissions on the `/var/www/myclient` web server directory without the setgid bit.

```js
grunt.initConfig({
  setmymode: {
    options: {
      directory: "/var/www/myclient"
    },
    main: {
      modeDirs: "0771"
    }
  },
});
```

#### Additional Files
In this example, custom options are used to set permissions on the `/var/www/myclient` web server directory without the setgid bit.

```js
grunt.initConfig({
  setmymode: {
    options: {
      directory: "/var/www/myclient"
    },
    main: {
      modeDirs: "0771"
      files: [ "/var/www/favicon.ico" ]
    }
  },
});
```

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

## Release History
_(Nothing yet)_

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