├── .DS_Store
├── .editorconfig
├── .eslintrc.json
├── .gitattributes
├── .gitignore
├── .travis.yml
├── .verb.md
├── LICENSE
├── README.md
├── docs
└── demo.gif
├── generator.js
├── index.js
├── package.json
├── templates
└── coc.md
└── test
├── plugin.js
└── test.js
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generate/generate-coc/27169028fb4a86165ff777c6e7b75b68182d9cdf/.DS_Store
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 |
10 | [*.md]
11 | trim_trailing_whitespace = false
12 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "ecmaFeatures": {
3 | "modules": true,
4 | "experimentalObjectRestSpread": true
5 | },
6 | "env": {
7 | "browser": false,
8 | "es6": true,
9 | "node": true,
10 | "mocha": true
11 | },
12 | "globals": {
13 | "document": false,
14 | "navigator": false,
15 | "window": false
16 | },
17 | "rules": {
18 | "accessor-pairs": 2,
19 | "arrow-spacing": [
20 | 2,
21 | {
22 | "before": true,
23 | "after": true
24 | }
25 | ],
26 | "block-spacing": [
27 | 2,
28 | "always"
29 | ],
30 | "brace-style": [
31 | 2,
32 | "1tbs",
33 | {
34 | "allowSingleLine": true
35 | }
36 | ],
37 | "comma-dangle": [
38 | 2,
39 | "never"
40 | ],
41 | "comma-spacing": [
42 | 2,
43 | {
44 | "before": false,
45 | "after": true
46 | }
47 | ],
48 | "comma-style": [
49 | 2,
50 | "last"
51 | ],
52 | "constructor-super": 2,
53 | "curly": [
54 | 2,
55 | "multi-line"
56 | ],
57 | "dot-location": [
58 | 2,
59 | "property"
60 | ],
61 | "eol-last": 2,
62 | "eqeqeq": [
63 | 2,
64 | "allow-null"
65 | ],
66 | "generator-star-spacing": [
67 | 2,
68 | {
69 | "before": true,
70 | "after": true
71 | }
72 | ],
73 | "handle-callback-err": [
74 | 2,
75 | "^(err|error)$"
76 | ],
77 | "indent": [
78 | 2,
79 | 2,
80 | {
81 | "SwitchCase": 1
82 | }
83 | ],
84 | "key-spacing": [
85 | 2,
86 | {
87 | "beforeColon": false,
88 | "afterColon": true
89 | }
90 | ],
91 | "keyword-spacing": [
92 | 2,
93 | {
94 | "before": true,
95 | "after": true
96 | }
97 | ],
98 | "new-cap": [
99 | 2,
100 | {
101 | "newIsCap": true,
102 | "capIsNew": false
103 | }
104 | ],
105 | "new-parens": 2,
106 | "no-array-constructor": 2,
107 | "no-caller": 2,
108 | "no-class-assign": 2,
109 | "no-cond-assign": 2,
110 | "no-const-assign": 2,
111 | "no-control-regex": 2,
112 | "no-debugger": 2,
113 | "no-delete-var": 2,
114 | "no-dupe-args": 2,
115 | "no-dupe-class-members": 2,
116 | "no-dupe-keys": 2,
117 | "no-duplicate-case": 2,
118 | "no-empty-character-class": 2,
119 | "no-eval": 2,
120 | "no-ex-assign": 2,
121 | "no-extend-native": 2,
122 | "no-extra-bind": 2,
123 | "no-extra-boolean-cast": 2,
124 | "no-extra-parens": [
125 | 2,
126 | "functions"
127 | ],
128 | "no-fallthrough": 2,
129 | "no-floating-decimal": 2,
130 | "no-func-assign": 2,
131 | "no-implied-eval": 2,
132 | "no-inner-declarations": [
133 | 2,
134 | "functions"
135 | ],
136 | "no-invalid-regexp": 2,
137 | "no-irregular-whitespace": 2,
138 | "no-iterator": 2,
139 | "no-label-var": 2,
140 | "no-labels": 2,
141 | "no-lone-blocks": 2,
142 | "no-mixed-spaces-and-tabs": 2,
143 | "no-multi-spaces": 2,
144 | "no-multi-str": 2,
145 | "no-multiple-empty-lines": [
146 | 2,
147 | {
148 | "max": 1
149 | }
150 | ],
151 | "no-native-reassign": 0,
152 | "no-negated-in-lhs": 2,
153 | "no-new": 2,
154 | "no-new-func": 2,
155 | "no-new-object": 2,
156 | "no-new-require": 2,
157 | "no-new-wrappers": 2,
158 | "no-obj-calls": 2,
159 | "no-octal": 2,
160 | "no-octal-escape": 2,
161 | "no-proto": 0,
162 | "no-redeclare": 2,
163 | "no-regex-spaces": 2,
164 | "no-return-assign": 2,
165 | "no-self-compare": 2,
166 | "no-sequences": 2,
167 | "no-shadow-restricted-names": 2,
168 | "no-spaced-func": 2,
169 | "no-sparse-arrays": 2,
170 | "no-this-before-super": 2,
171 | "no-throw-literal": 2,
172 | "no-trailing-spaces": 0,
173 | "no-undef": 2,
174 | "no-undef-init": 2,
175 | "no-unexpected-multiline": 2,
176 | "no-unneeded-ternary": [
177 | 2,
178 | {
179 | "defaultAssignment": false
180 | }
181 | ],
182 | "no-unreachable": 2,
183 | "no-unused-vars": [
184 | 2,
185 | {
186 | "vars": "all",
187 | "args": "none"
188 | }
189 | ],
190 | "no-useless-call": 0,
191 | "no-with": 2,
192 | "one-var": [
193 | 0,
194 | {
195 | "initialized": "never"
196 | }
197 | ],
198 | "operator-linebreak": [
199 | 0,
200 | "after",
201 | {
202 | "overrides": {
203 | "?": "before",
204 | ":": "before"
205 | }
206 | }
207 | ],
208 | "padded-blocks": [
209 | 0,
210 | "never"
211 | ],
212 | "quotes": [
213 | 2,
214 | "single",
215 | "avoid-escape"
216 | ],
217 | "radix": 2,
218 | "semi": [
219 | 2,
220 | "always"
221 | ],
222 | "semi-spacing": [
223 | 2,
224 | {
225 | "before": false,
226 | "after": true
227 | }
228 | ],
229 | "space-before-blocks": [
230 | 2,
231 | "always"
232 | ],
233 | "space-before-function-paren": [
234 | 2,
235 | "never"
236 | ],
237 | "space-in-parens": [
238 | 2,
239 | "never"
240 | ],
241 | "space-infix-ops": 2,
242 | "space-unary-ops": [
243 | 2,
244 | {
245 | "words": true,
246 | "nonwords": false
247 | }
248 | ],
249 | "spaced-comment": [
250 | 0,
251 | "always",
252 | {
253 | "markers": [
254 | "global",
255 | "globals",
256 | "eslint",
257 | "eslint-disable",
258 | "*package",
259 | "!",
260 | ","
261 | ]
262 | }
263 | ],
264 | "use-isnan": 2,
265 | "valid-typeof": 2,
266 | "wrap-iife": [
267 | 2,
268 | "any"
269 | ],
270 | "yoda": [
271 | 2,
272 | "never"
273 | ]
274 | }
275 | }
276 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Enforce Unix newlines
2 | * text eol=lf
3 |
4 | # binaries
5 | *.ai binary
6 | *.psd binary
7 | *.jpg binary
8 | *.gif binary
9 | *.png binary
10 | *.jpeg binary
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - "6"
5 | - "5"
6 | - "4"
7 | - "0.12"
8 | - "0.10"
9 | matrix:
10 | fast_finish: true
11 | allow_failures:
12 | - node_js: "4"
13 | - node_js: "0.10"
14 | - node_js: "0.12"
15 |
--------------------------------------------------------------------------------
/.verb.md:
--------------------------------------------------------------------------------
1 | ## Quickstart
2 |
3 | Visit the [ContributorCovenant/contributor_covenant](https://github.com/ContributorCovenant/contributor_covenant) project for more details.
4 |
5 | **Install**
6 |
7 | Install [generate][] and `{%= name %}`:
8 |
9 | ```sh
10 | $ npm install --global generate {%= name %}
11 | ```
12 |
13 | **Generate a contributor convenant**
14 |
15 | To generate a `CODE_OF_CONDUCT.md` file to the current working directory, run:
16 |
17 | ```sh
18 | $ gen {%= alias %}
19 | ```
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Jon Schlinkert
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Generate a CODE_OF_CONDUCT.md file for a project (Contributor Covenant Code of Conduct). Use from the command line when Generate's CLI is installed globally, or use as a plugin or sub-generator in your own generator.
9 |
10 | # generate-coc
11 |
12 | [](https://www.npmjs.com/package/generate-coc) [](https://npmjs.org/package/generate-coc) [](https://travis-ci.org/generate/generate-coc)
13 |
14 | 
15 |
16 | ## Quickstart
17 |
18 | Visit the [ContributorCovenant/contributor_covenant](https://github.com/ContributorCovenant/contributor_covenant) project for more details.
19 |
20 | **Install**
21 |
22 | Install [generate](https://github.com/generate/generate) and `generate-coc`:
23 |
24 | ```sh
25 | $ npm install --global generate generate-coc
26 | ```
27 |
28 | **Generate a contributor convenant**
29 |
30 | To generate a `CODE_OF_CONDUCT.md` file to the current working directory, run:
31 |
32 | ```sh
33 | $ gen coc
34 | ```
35 |
36 | ## What is "Generate"?
37 |
38 | Generate is a command line tool and developer framework for scaffolding out new GitHub projects using [generators](https://github.com/generate/generate/blob/master/docs/generators.md) and [tasks](https://github.com/generate/generate/blob/master/docs/tasks.md).
39 |
40 | Answers to prompts and the user's environment can be used to determine the templates, directories, files and contents to build. Support for [gulp](http://gulpjs.com), [base](https://github.com/node-base/base) and [assemble](https://github.com/assemble/assemble) plugins, and much more.
41 |
42 | **For more information**:
43 |
44 | * Visit the [generate project](https://github.com/generate/generate/)
45 | * Visit the [generate documentation](https://github.com/generate/generate/blob/master/docs/)
46 | * Find [generators on npm](https://www.npmjs.com/browse/keyword/generate-generator) (help us [author generators](https://github.com/generate/generate/blob/master/docs/micro-generators.md))
47 |
48 | ## Getting started
49 |
50 | ### Install
51 |
52 | **Installing the CLI**
53 |
54 | To run the `coc` generator from the command line, you'll need to install [Generate](https://github.com/generate/generate) globally first. You can do that now with the following command:
55 |
56 | ```sh
57 | $ npm install --global generate
58 | ```
59 |
60 | This adds the `gen` command to your system path, allowing it to be run from any directory.
61 |
62 | **Install generate-coc**
63 |
64 | Install this module with the following command:
65 |
66 | ```sh
67 | $ npm install --global generate-coc
68 | ```
69 |
70 | ### Usage
71 |
72 | Run this generator's `default` [task](https://github.com/generate/generate/blob/master/docs/tasks.md#default) with the following command:
73 |
74 | ```sh
75 | $ gen coc
76 | ```
77 |
78 | **What you should see in the terminal**
79 |
80 | If completed successfully, you should see both `starting` and `finished` events in the terminal, like the following:
81 |
82 | ```sh
83 | [00:44:21] starting ...
84 | ...
85 | [00:44:22] finished ✔
86 | ```
87 |
88 | If you do not see one or both of those events, please [let us know about it](../../issues).
89 |
90 | ### Help
91 |
92 | To see a general help menu and available commands for Generate's CLI, run:
93 |
94 | ```sh
95 | $ gen help
96 | ```
97 |
98 | ## Tasks
99 |
100 | All available tasks.
101 |
102 | ### [coc](generator.js#L27)
103 |
104 | Generates a `coc` file to the current working directory or specified `--dest`.
105 |
106 | **Example**
107 |
108 | ```sh
109 | $ gen coc
110 | $ gen coc --dest ./foo
111 | ```
112 |
113 | Visit Generate's [documentation for tasks](https://github.com/generate/generate/blob/master/docs/tasks.md).
114 |
115 | ## Next steps
116 |
117 | ### Running unit tests
118 |
119 | It's never too early to begin running unit tests. When you're ready to get started, the following command will ensure the project's dependencies are installed then run all of the unit tests:
120 |
121 | ```sh
122 | $ npm install && test
123 | ```
124 |
125 | ### Publishing your generator
126 |
127 | If you're tests are passing and you're ready to publish your generator to [npm](https://www.npmjs.com), you can do that now with the following command:
128 |
129 | **Are you sure you're ready?!**
130 |
131 | Let's go!
132 |
133 | ```sh
134 | $ npm publish
135 | ```
136 |
137 | ## About
138 |
139 | ### Community
140 |
141 | Are you using [Generate](https://github.com/generate/generate) in your project? Have you published a [generator](https://github.com/generate/generate/blob/master/docs/generators.md) and want to share your project with the world?
142 |
143 | Here are some suggestions!
144 |
145 | * If you get like Generate and want to tweet about it, please feel free to mention `@generatejs` or use the `#generatejs` hashtag
146 | * Show your love by starring [Generate](https://github.com/generate/generate) and `generate-coc`
147 | * Get implementation help on [StackOverflow](http://stackoverflow.com/questions/tagged/generate) (please use the `generatejs` tag in questions)
148 | * **Gitter** Discuss Generate with us on [Gitter](https://gitter.im/generate/generate)
149 | * If you publish an generator, thank you! To make your project as discoverable as possible, please add the keyword `generategenerator` to package.json.
150 |
151 | ### Contributing
152 |
153 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
154 |
155 | ### Running tests
156 |
157 | Install dev dependencies:
158 |
159 | ```sh
160 | $ npm install -d && npm test
161 | ```
162 |
163 | ### Author
164 |
165 | **Jon Schlinkert**
166 |
167 | * [github/jonschlinkert](https://github.com/jonschlinkert)
168 | * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
169 |
170 | ### License
171 |
172 | Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
173 | Released under the [MIT license](https://github.com/generate/generate-coc/blob/master/LICENSE).
174 |
175 | ***
176 |
177 | _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.30, on August 19, 2016._
--------------------------------------------------------------------------------
/docs/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generate/generate-coc/27169028fb4a86165ff777c6e7b75b68182d9cdf/docs/demo.gif
--------------------------------------------------------------------------------
/generator.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var isValid = require('is-valid-app');
4 |
5 | module.exports = function(app) {
6 | // return if the generator is already registered
7 | if (!isValid(app, 'generate-coc')) return;
8 |
9 | /**
10 | * Plugins
11 | */
12 |
13 | app.use(require('generate-defaults'));
14 |
15 | /**
16 | * Generates a `coc` file to the current working directory or
17 | * specified `--dest`.
18 | *
19 | * ```sh
20 | * $ gen coc
21 | * $ gen coc --dest ./foo
22 | * ```
23 | * @name coc
24 | * @api public
25 | */
26 |
27 | app.task('default', ['coc']);
28 | app.task('coc', function(cb) {
29 | return app.src('templates/coc.md', { cwd: __dirname })
30 | .pipe(app.renderFile('*')).on('error', console.log)
31 | .pipe(app.conflicts(app.cwd))
32 | .pipe(app.dest(app.cwd))
33 | });
34 | };
35 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./generator');
2 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generate-coc",
3 | "description": "Generate a CODE_OF_CONDUCT.md file for a project (Contributor Covenant Code of Conduct). Use from the command line when Generate's CLI is installed globally, or use as a plugin or sub-generator in your own generator.",
4 | "version": "0.1.1",
5 | "homepage": "https://github.com/generate/generate-coc",
6 | "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7 | "repository": "generate/generate-coc",
8 | "bugs": {
9 | "url": "https://github.com/generate/generate-coc/issues"
10 | },
11 | "license": "MIT",
12 | "files": [
13 | "generator.js",
14 | "index.js",
15 | "LICENSE",
16 | "templates"
17 | ],
18 | "main": "index.js",
19 | "engines": {
20 | "node": ">=0.10.0"
21 | },
22 | "scripts": {
23 | "test": "mocha"
24 | },
25 | "keywords": [
26 | "coc",
27 | "generate"
28 | ],
29 | "devDependencies": {
30 | "delete": "^0.3.2",
31 | "generate": "^0.11.2",
32 | "gulp-format-md": "^0.1.10",
33 | "mocha": "^3.0.2",
34 | "npm-install-global": "^0.1.2"
35 | },
36 | "dependencies": {
37 | "generate-defaults": "^0.6.0",
38 | "is-valid-app": "^0.2.0"
39 | },
40 | "verb": {
41 | "toc": false,
42 | "layout": "generator",
43 | "tasks": [
44 | "readme"
45 | ],
46 | "plugins": [
47 | "gulp-format-md"
48 | ],
49 | "lint": {
50 | "reflinks": true
51 | },
52 | "related": {
53 | "list": []
54 | },
55 | "reflinks": [
56 | "assemble",
57 | "base",
58 | "generate",
59 | "gulp"
60 | ]
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/templates/coc.md:
--------------------------------------------------------------------------------
1 | ---
2 | rename:
3 | basename: CODE_OF_CONDUCT.md
4 | ---
5 | # Contributor Covenant Code of Conduct
6 |
7 | ## Our Pledge
8 |
9 | In the interest of fostering an open and welcoming environment, we as
10 | contributors and maintainers pledge to making participation in our project and
11 | our community a harassment-free experience for everyone, regardless of age, body
12 | size, disability, ethnicity, gender identity and expression, level of experience,
13 | nationality, personal appearance, race, religion, or sexual identity and
14 | orientation.
15 |
16 | ## Our Standards
17 |
18 | Examples of behavior that contributes to creating a positive environment
19 | include:
20 |
21 | * Using welcoming and inclusive language
22 | * Being respectful of differing viewpoints and experiences
23 | * Gracefully accepting constructive criticism
24 | * Focusing on what is best for the community
25 | * Showing empathy towards other community members
26 |
27 | Examples of unacceptable behavior by participants include:
28 |
29 | * The use of sexualized language or imagery and unwelcome sexual attention or
30 | advances
31 | * Trolling, insulting/derogatory comments, and personal or political attacks
32 | * Public or private harassment
33 | * Publishing others' private information, such as a physical or electronic
34 | address, without explicit permission
35 | * Other conduct which could reasonably be considered inappropriate in a
36 | professional setting
37 |
38 | ## Our Responsibilities
39 |
40 | Project maintainers are responsible for clarifying the standards of acceptable
41 | behavior and are expected to take appropriate and fair corrective action in
42 | response to any instances of unacceptable behavior.
43 |
44 | Project maintainers have the right and responsibility to remove, edit, or
45 | reject comments, commits, code, wiki edits, issues, and other contributions
46 | that are not aligned to this Code of Conduct, or to ban temporarily or
47 | permanently any contributor for other behaviors that they deem inappropriate,
48 | threatening, offensive, or harmful.
49 |
50 | ## Scope
51 |
52 | This Code of Conduct applies both within project spaces and in public spaces
53 | when an individual is representing the project or its community. Examples of
54 | representing a project or community include using an official project e-mail
55 | address, posting via an official social media account, or acting as an appointed
56 | representative at an online or offline event. Representation of a project may be
57 | further defined and clarified by project maintainers.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported by contacting the project team at <%= ask("author.email", "Email address?") %>. All
63 | complaints will be reviewed and investigated and will result in a response that
64 | is deemed necessary and appropriate to the circumstances. The project team is
65 | obligated to maintain confidentiality with regard to the reporter of an incident.
66 | Further details of specific enforcement policies may be posted separately.
67 |
68 | Project maintainers who do not follow or enforce the Code of Conduct in good
69 | faith may face temporary or permanent repercussions as determined by other
70 | members of the project's leadership.
71 |
72 | ## Attribution
73 |
74 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
75 | available at [http://contributor-covenant.org/version/1/4][version]
76 |
77 | [homepage]: http://contributor-covenant.org
78 | [version]: http://contributor-covenant.org/version/1/4/
--------------------------------------------------------------------------------
/test/plugin.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | require('mocha');
4 | var assert = require('assert');
5 | var generate = require('generate');
6 | var generator = require('..');
7 | var app;
8 |
9 | describe('generate-coc', function() {
10 | beforeEach(function() {
11 | app = generate();
12 | });
13 |
14 | describe('plugin', function() {
15 | it('should add tasks to the instance', function() {
16 | app.use(generator);
17 | assert(app.tasks.hasOwnProperty('default'));
18 | assert(app.tasks.hasOwnProperty('coc'));
19 | });
20 |
21 | it('should only register the plugin once', function(cb) {
22 | var count = 0;
23 | app.on('plugin', function(name) {
24 | if (name === 'generate-coc') {
25 | count++;
26 | }
27 | });
28 | app.use(generator);
29 | app.use(generator);
30 | app.use(generator);
31 | assert.equal(count, 1);
32 | cb();
33 | });
34 | });
35 | });
36 |
--------------------------------------------------------------------------------
/test/test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | require('mocha');
4 | var fs = require('fs');
5 | var path = require('path');
6 | var assert = require('assert');
7 | var generate = require('generate');
8 | var npm = require('npm-install-global');
9 | var del = require('delete');
10 | var pkg = require('../package');
11 | var generator = require('..');
12 | var app;
13 |
14 | var isTravis = process.env.CI || process.env.TRAVIS;
15 | var fixtures = path.resolve.bind(path, __dirname, 'fixtures');
16 | var actual = path.resolve.bind(path, __dirname, 'actual');
17 |
18 | function exists(name, cb) {
19 | return function(err) {
20 | if (err) return cb(err);
21 | var filepath = actual(name);
22 |
23 | fs.stat(filepath, function(err, stat) {
24 | if (err) return cb(err);
25 | del(actual(), cb);
26 | });
27 | };
28 | }
29 |
30 | describe('generate-coc', function() {
31 | this.slow(250);
32 |
33 | if (!isTravis) {
34 | before(function(cb) {
35 | npm.maybeInstall('generate', cb);
36 | });
37 | }
38 |
39 | beforeEach(function() {
40 | app = generate({silent: true});
41 | app.cwd = actual();
42 | app.option('dest', actual());
43 |
44 | // see: https://github.com/jonschlinkert/ask-when
45 | app.option('askWhen', 'not-answered');
46 | app.preRender(/./, function(file, next) {
47 | file.set('data.author.email', 'jon.schlinkert@sellside.com');
48 | next();
49 | });
50 | });
51 |
52 | describe('tasks', function() {
53 | it('should extend tasks onto the instance', function() {
54 | app.use(generator);
55 | assert(app.tasks.hasOwnProperty('default'));
56 | assert(app.tasks.hasOwnProperty('coc'));
57 | });
58 |
59 | it('should run the `default` task with .build', function(cb) {
60 | app.use(generator);
61 | app.build('default', exists('CODE_OF_CONDUCT.md', cb));
62 | });
63 |
64 | it('should run the `default` task with .generate', function(cb) {
65 | app.use(generator);
66 | app.generate('default', exists('CODE_OF_CONDUCT.md', cb));
67 | });
68 | });
69 |
70 | describe('coc (CLI)', function() {
71 | it('should run the default task using the `generate-coc` name', function(cb) {
72 | if (isTravis) return this.skip();
73 |
74 | app.use(generator);
75 | app.generate('generate-coc', exists('CODE_OF_CONDUCT.md', cb));
76 | });
77 |
78 | it('should run the default task using the `generator` generator alias', function(cb) {
79 | if (isTravis) return this.skip();
80 |
81 | app.use(generator);
82 | app.generate('coc', exists('CODE_OF_CONDUCT.md', cb));
83 | });
84 | });
85 |
86 | describe('coc (API)', function() {
87 | it('should run the default task on the generator', function(cb) {
88 | app.register('coc', generator);
89 | app.generate('coc', exists('CODE_OF_CONDUCT.md', cb));
90 | });
91 |
92 | it('should run the `coc` task', function(cb) {
93 | app.register('coc', generator);
94 | app.generate('coc:coc', exists('CODE_OF_CONDUCT.md', cb));
95 | });
96 |
97 | it('should run the `default` task when defined explicitly', function(cb) {
98 | app.register('coc', generator);
99 | app.generate('coc:default', exists('CODE_OF_CONDUCT.md', cb));
100 | });
101 | });
102 |
103 | describe('sub-generator', function() {
104 | it('should work as a sub-generator', function(cb) {
105 | app.register('foo', function(foo) {
106 | foo.register('coc', generator);
107 | });
108 | app.generate('foo.coc', exists('CODE_OF_CONDUCT.md', cb));
109 | });
110 |
111 | it('should run the `default` task by default', function(cb) {
112 | app.register('foo', function(foo) {
113 | foo.register('coc', generator);
114 | });
115 | app.generate('foo.coc', exists('CODE_OF_CONDUCT.md', cb));
116 | });
117 |
118 | it('should run the `generator:default` task when defined explicitly', function(cb) {
119 | app.register('foo', function(foo) {
120 | foo.register('coc', generator);
121 | });
122 | app.generate('foo.coc:default', exists('CODE_OF_CONDUCT.md', cb));
123 | });
124 |
125 | it('should run the `generator:coc` task', function(cb) {
126 | app.register('foo', function(foo) {
127 | foo.register('coc', generator);
128 | });
129 | app.generate('foo.coc:coc', exists('CODE_OF_CONDUCT.md', cb));
130 | });
131 |
132 | it('should work with nested sub-generators', function(cb) {
133 | app
134 | .register('foo', generator)
135 | .register('bar', generator)
136 | .register('baz', generator);
137 | app.generate('foo.bar.baz', exists('CODE_OF_CONDUCT.md', cb));
138 | });
139 | });
140 | });
141 |
--------------------------------------------------------------------------------