├── .editorconfig
├── .eslintrc.json
├── .gitattributes
├── .gitignore
├── .travis.yml
├── .verb.md
├── LICENSE
├── README.md
├── changelog.md
├── docs
└── demo.gif
├── generator.js
├── index.js
├── package.json
├── templates
└── changelog.md
└── test
├── plugin.js
└── test.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | end_of_line = lf
6 | charset = utf-8
7 | indent_size = 2
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [{**/{actual,fixtures,expected,templates}/**,*.md}]
12 | trim_trailing_whitespace = false
13 | insert_final_newline = false
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "ecmaFeatures": {
3 | "modules": true,
4 | "experimentalObjectRestSpread": true
5 | },
6 |
7 | "env": {
8 | "browser": false,
9 | "es6": true,
10 | "node": true,
11 | "mocha": true
12 | },
13 |
14 | "globals": {
15 | "document": false,
16 | "navigator": false,
17 | "window": false
18 | },
19 |
20 | "rules": {
21 | "accessor-pairs": 2,
22 | "arrow-spacing": [2, { "before": true, "after": true }],
23 | "block-spacing": [2, "always"],
24 | "brace-style": [2, "1tbs", { "allowSingleLine": true }],
25 | "comma-dangle": [2, "never"],
26 | "comma-spacing": [2, { "before": false, "after": true }],
27 | "comma-style": [2, "last"],
28 | "constructor-super": 2,
29 | "curly": [2, "multi-line"],
30 | "dot-location": [2, "property"],
31 | "eol-last": 2,
32 | "eqeqeq": [2, "allow-null"],
33 | "generator-star-spacing": [2, { "before": true, "after": true }],
34 | "handle-callback-err": [2, "^(err|error)$" ],
35 | "indent": [2, 2, { "SwitchCase": 1 }],
36 | "key-spacing": [2, { "beforeColon": false, "afterColon": true }],
37 | "keyword-spacing": [2, { "before": true, "after": true }],
38 | "new-cap": [2, { "newIsCap": true, "capIsNew": false }],
39 | "new-parens": 2,
40 | "no-array-constructor": 2,
41 | "no-caller": 2,
42 | "no-class-assign": 2,
43 | "no-cond-assign": 2,
44 | "no-const-assign": 2,
45 | "no-control-regex": 2,
46 | "no-debugger": 2,
47 | "no-delete-var": 2,
48 | "no-dupe-args": 2,
49 | "no-dupe-class-members": 2,
50 | "no-dupe-keys": 2,
51 | "no-duplicate-case": 2,
52 | "no-empty-character-class": 2,
53 | "no-eval": 2,
54 | "no-ex-assign": 2,
55 | "no-extend-native": 2,
56 | "no-extra-bind": 2,
57 | "no-extra-boolean-cast": 2,
58 | "no-extra-parens": [2, "functions"],
59 | "no-fallthrough": 2,
60 | "no-floating-decimal": 2,
61 | "no-func-assign": 2,
62 | "no-implied-eval": 2,
63 | "no-inner-declarations": [2, "functions"],
64 | "no-invalid-regexp": 2,
65 | "no-irregular-whitespace": 2,
66 | "no-iterator": 2,
67 | "no-label-var": 2,
68 | "no-labels": 2,
69 | "no-lone-blocks": 2,
70 | "no-mixed-spaces-and-tabs": 2,
71 | "no-multi-spaces": 2,
72 | "no-multi-str": 2,
73 | "no-multiple-empty-lines": [2, { "max": 1 }],
74 | "no-native-reassign": 0,
75 | "no-negated-in-lhs": 2,
76 | "no-new": 2,
77 | "no-new-func": 2,
78 | "no-new-object": 2,
79 | "no-new-require": 2,
80 | "no-new-wrappers": 2,
81 | "no-obj-calls": 2,
82 | "no-octal": 2,
83 | "no-octal-escape": 2,
84 | "no-proto": 0,
85 | "no-redeclare": 2,
86 | "no-regex-spaces": 2,
87 | "no-return-assign": 2,
88 | "no-self-compare": 2,
89 | "no-sequences": 2,
90 | "no-shadow-restricted-names": 2,
91 | "no-spaced-func": 2,
92 | "no-sparse-arrays": 2,
93 | "no-this-before-super": 2,
94 | "no-throw-literal": 2,
95 | "no-trailing-spaces": 0,
96 | "no-undef": 2,
97 | "no-undef-init": 2,
98 | "no-unexpected-multiline": 2,
99 | "no-unneeded-ternary": [2, { "defaultAssignment": false }],
100 | "no-unreachable": 2,
101 | "no-unused-vars": [2, { "vars": "all", "args": "none" }],
102 | "no-useless-call": 0,
103 | "no-with": 2,
104 | "one-var": [0, { "initialized": "never" }],
105 | "operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }],
106 | "padded-blocks": [0, "never"],
107 | "quotes": [2, "single", "avoid-escape"],
108 | "radix": 2,
109 | "semi": [2, "always"],
110 | "semi-spacing": [2, { "before": false, "after": true }],
111 | "space-before-blocks": [2, "always"],
112 | "space-before-function-paren": [2, "never"],
113 | "space-in-parens": [2, "never"],
114 | "space-infix-ops": 2,
115 | "space-unary-ops": [2, { "words": true, "nonwords": false }],
116 | "spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }],
117 | "use-isnan": 2,
118 | "valid-typeof": 2,
119 | "wrap-iife": [2, "any"],
120 | "yoda": [2, "never"]
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # always ignore files
2 | *.DS_Store
3 | *.sublime-*
4 |
5 | # test related, or directories generated by tests
6 | test/actual
7 | actual
8 | coverage
9 |
10 | # npm
11 | node_modules
12 | npm-debug.log
13 |
14 | # misc
15 | _gh_pages
16 | benchmark
17 | bower_components
18 | vendor
19 | temp
20 | tmp
21 | TODO.md
22 |
--------------------------------------------------------------------------------
/.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 | **Install**
4 |
5 | Install [generate][] and `{%= name %}`:
6 |
7 | ```sh
8 | $ npm install --global generate {%= name %}
9 | ```
10 |
11 | **Generate a CHANGELOG.md file**
12 |
13 | Generate a `CHANGELOG.md` file to the current working directory:
14 |
15 | ```sh
16 | $ gen {%= alias %}
17 | ```
18 |
--------------------------------------------------------------------------------
/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
13 | all 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
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Generate a starter CHANGELOG.md file, using conventions from keep-a-changelog. 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-log
11 |
12 | [](https://www.npmjs.com/package/generate-log) [](https://npmjs.org/package/generate-log) [](https://travis-ci.org/generate/generate-log)
13 |
14 | 
15 |
16 | ## Table of Contents
17 |
18 | - [Quickstart](#quickstart)
19 | - [What is "Generate"?](#what-is-generate)
20 | - [Getting started](#getting-started)
21 | * [Install](#install)
22 | * [Usage](#usage)
23 | * [Help](#help)
24 | - [About](#about)
25 | * [Related projects](#related-projects)
26 | * [Community](#community)
27 | * [Contributing](#contributing)
28 | * [Running tests](#running-tests)
29 | * [Release history](#release-history)
30 | * [Author](#author)
31 | * [License](#license)
32 |
33 | _(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
34 |
35 | ## Quickstart
36 |
37 | **Install**
38 |
39 | Install [generate](https://github.com/generate/generate) and `generate-log`:
40 |
41 | ```sh
42 | $ npm install --global generate generate-log
43 | ```
44 |
45 | **Generate a CHANGELOG.md file**
46 |
47 | Generate a `CHANGELOG.md` file to the current working directory:
48 |
49 | ```sh
50 | $ gen log
51 | ```
52 |
53 | ## What is "Generate"?
54 |
55 | 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).
56 |
57 | 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.
58 |
59 | **For more information**:
60 |
61 | * Visit the [generate project](https://github.com/generate/generate/)
62 | * Visit the [generate documentation](https://github.com/generate/generate/blob/master/docs/)
63 | * 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))
64 |
65 | ## Getting started
66 |
67 | ### Install
68 |
69 | **Installing the CLI**
70 |
71 | To run the `log` 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:
72 |
73 | ```sh
74 | $ npm install --global generate
75 | ```
76 |
77 | This adds the `gen` command to your system path, allowing it to be run from any directory.
78 |
79 | **Install generate-log**
80 |
81 | Install this module with the following command:
82 |
83 | ```sh
84 | $ npm install --global generate-log
85 | ```
86 |
87 | ### Usage
88 |
89 | Run this generator's `default` [task](https://github.com/generate/generate/blob/master/docs/tasks.md#default) with the following command:
90 |
91 | ```sh
92 | $ gen log
93 | ```
94 |
95 | **What you should see in the terminal**
96 |
97 | If completed successfully, you should see both `starting` and `finished` events in the terminal, like the following:
98 |
99 | ```sh
100 | [00:44:21] starting ...
101 | ...
102 | [00:44:22] finished ✔
103 | ```
104 |
105 | If you do not see one or both of those events, please [let us know about it](../../issues).
106 |
107 | ### Help
108 |
109 | To see a general help menu and available commands for Generate's CLI, run:
110 |
111 | ```sh
112 | $ gen help
113 | ```
114 |
115 | ## Tasks
116 |
117 | All available tasks.
118 |
119 | ### [log](generator.js#L24)
120 |
121 | Generate a `changelog.md` file. For API usage this task is also aliased as `changelog`.
122 |
123 | **Example**
124 |
125 | ```sh
126 | $ gen generator:log
127 | ```
128 |
129 | Visit Generate's [documentation for tasks](https://github.com/generate/generate/blob/master/docs/tasks.md).
130 |
131 | ## Next steps
132 |
133 | ### Running unit tests
134 |
135 | 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:
136 |
137 | ```sh
138 | $ npm install && test
139 | ```
140 |
141 | ### Publishing your generator
142 |
143 | 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:
144 |
145 | **Are you sure you're ready?!**
146 |
147 | Let's go!
148 |
149 | ```sh
150 | $ npm publish
151 | ```
152 |
153 | ## About
154 |
155 | ### Related projects
156 |
157 | * [generate-gitignore](https://www.npmjs.com/package/generate-gitignore): Generate a .gitignore file from the command line when Generate's CLI is installed globally, or… [more](https://github.com/generate/generate-gitignore) | [homepage](https://github.com/generate/generate-gitignore "Generate a .gitignore file from the command line when Generate's CLI is installed globally, or use as a plugin or sub-generator in your own generator to make it a continuous part of the build workflow when scaffolding out a new project.")
158 | * [generate-license](https://www.npmjs.com/package/generate-license): Generate a license file for a GitHub project. | [homepage](https://github.com/generate/generate-license "Generate a license file for a GitHub project.")
159 | * [generate-project](https://www.npmjs.com/package/generate-project): Scaffold out complete code projects from the command line, or use this generator as a… [more](https://github.com/generate/generate-project) | [homepage](https://github.com/generate/generate-project "Scaffold out complete code projects from the command line, or use this generator as a plugin in other generators to provide baseline functionality.")
160 |
161 | ### Community
162 |
163 | 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?
164 |
165 | Here are some suggestions!
166 |
167 | * If you get like Generate and want to tweet about it, please feel free to mention `@generatejs` or use the `#generatejs` hashtag
168 | * Show your love by starring [Generate](https://github.com/generate/generate) and `generate-log`
169 | * Get implementation help on [StackOverflow](http://stackoverflow.com/questions/tagged/generate) (please use the `generatejs` tag in questions)
170 | * **Gitter** Discuss Generate with us on [Gitter](https://gitter.im/generate/generate)
171 | * If you publish an generator, thank you! To make your project as discoverable as possible, please add the keyword `generategenerator` to package.json.
172 |
173 | ### Contributing
174 |
175 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
176 |
177 | ### Running tests
178 |
179 | Install dev dependencies:
180 |
181 | ```sh
182 | $ npm install -d && npm test
183 | ```
184 |
185 | ### Author
186 |
187 | **Jon Schlinkert**
188 |
189 | * [github/jonschlinkert](https://github.com/jonschlinkert)
190 | * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
191 |
192 | ### License
193 |
194 | Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
195 | Released under the [MIT license](https://github.com/generate/generate-log/blob/master/LICENSE).
196 |
197 | ***
198 |
199 | _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.30, on August 19, 2016._
--------------------------------------------------------------------------------
/changelog.md:
--------------------------------------------------------------------------------
1 | #### key
2 |
3 | Changelog entries are classified using the following labels _(from [keep-a-changelog][]_):
4 |
5 | - `added`: for new features
6 | - `changed`: for changes in existing functionality
7 | - `deprecated`: for once-stable features removed in upcoming releases
8 | - `removed`: for deprecated features removed in this release
9 | - `fixed`: for any bug fixes
10 |
11 | #### Unreleased
12 |
13 | This is an example section. Update this with actual history.
14 |
15 | **Changed**
16 |
17 | - Description of something that was changed.
18 |
19 | **Added**
20 |
21 | - Description of something that was added.
22 |
23 | #### [0.1.0] - 2016-07-13
24 |
25 | First commit.
26 |
27 | [Unreleased]: https://github.com/jonschlinkert/generate-log/compare/0.1.0...HEAD
28 | [keep-a-changelog]: https://github.com/olivierlacan/keep-a-changelog
29 |
30 |
--------------------------------------------------------------------------------
/docs/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generate/generate-log/0a5a17697f63c941d082adac885e31ddee26f43f/docs/demo.gif
--------------------------------------------------------------------------------
/generator.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var isValid = require('is-valid-app');
4 |
5 | module.exports = function fn(app) {
6 | if (!isValid(app, 'generate-log')) return;
7 |
8 | /**
9 | * Plugins
10 | */
11 |
12 | app.use(require('generate-defaults'));
13 |
14 | /**
15 | * Generate a `changelog.md` file. For API usage this task is also aliased as `changelog`.
16 | *
17 | * ```sh
18 | * $ gen generator:log
19 | * ```
20 | * @name log
21 | * @api public
22 | */
23 |
24 | app.task('default', ['changelog']);
25 | app.task('changelog', function() {
26 | app.helper('date', require('helper-date'));
27 |
28 | return app.src('templates/CHANGELOG.md', {cwd: __dirname})
29 | .pipe(app.renderFile('*')).on('error', console.log)
30 | .pipe(app.conflicts(app.cwd))
31 | .pipe(app.dest(app.cwd));
32 | });
33 | };
34 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./generator');
2 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generate-log",
3 | "description": "Generate a starter CHANGELOG.md file, using conventions from keep-a-changelog. 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.3",
5 | "homepage": "https://github.com/generate/generate-log",
6 | "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7 | "contributors": [
8 | "Hien Dao vinh "
9 | ],
10 | "repository": "generate/generate-log",
11 | "bugs": {
12 | "url": "https://github.com/generate/generate-log/issues"
13 | },
14 | "license": "MIT",
15 | "files": [
16 | "generator.js",
17 | "index.js",
18 | "LICENSE",
19 | "README.md",
20 | "templates"
21 | ],
22 | "main": "index.js",
23 | "engines": {
24 | "node": ">=0.10.0"
25 | },
26 | "scripts": {
27 | "test": "mocha"
28 | },
29 | "dependencies": {
30 | "generate-defaults": "^0.6.0",
31 | "helper-date": "^0.2.2",
32 | "is-valid-app": "^0.2.0"
33 | },
34 | "devDependencies": {
35 | "delete": "^0.3.2",
36 | "generate": "^0.11.2",
37 | "gulp-format-md": "^0.1.10",
38 | "mixin-deep": "^1.1.3",
39 | "mocha": "^3.0.2",
40 | "npm-install-global": "^0.1.2"
41 | },
42 | "keywords": [
43 | "boilerplate",
44 | "build",
45 | "changelog",
46 | "cli",
47 | "cli-app",
48 | "command-line",
49 | "create",
50 | "dev",
51 | "development",
52 | "framework",
53 | "front",
54 | "frontend",
55 | "generate",
56 | "generate-generator",
57 | "generate-plugin",
58 | "generategenerator",
59 | "generateplugin",
60 | "generator",
61 | "init",
62 | "initialize",
63 | "log",
64 | "new",
65 | "plugin",
66 | "project",
67 | "projects",
68 | "scaffold",
69 | "scaffolder",
70 | "scaffolding",
71 | "template",
72 | "templates",
73 | "webapp",
74 | "yeoman",
75 | "yo"
76 | ],
77 | "verb": {
78 | "toc": true,
79 | "layout": "generator",
80 | "tasks": [
81 | "readme"
82 | ],
83 | "plugins": [
84 | "gulp-format-md"
85 | ],
86 | "related": {
87 | "list": [
88 | "generate-gitignore",
89 | "generate-license",
90 | "generate-project"
91 | ]
92 | },
93 | "reflinks": [
94 | "assemble",
95 | "base",
96 | "generate",
97 | "generate-dest",
98 | "generate-install",
99 | "gulp",
100 | "verb",
101 | "verb-generate-readme"
102 | ],
103 | "lint": {
104 | "reflinks": true
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/templates/changelog.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## key
4 |
5 | Changelog entries are classified using the following labels _(from [keep-a-changelog][]_):
6 |
7 | - `added`: for new features
8 | - `changed`: for changes in existing functionality
9 | - `deprecated`: for once-stable features removed in upcoming releases
10 | - `removed`: for deprecated features removed in this release
11 | - `fixed`: for any bug fixes
12 |
13 | ## Unreleased
14 |
15 | This is an example section. Update this with actual history.
16 |
17 | ### Changed
18 |
19 | - Description of something that was changed.
20 |
21 | ### Added
22 |
23 | - Description of something that was added.
24 |
25 | ## [0.1.0] - <%= date("YYYY-MM-DD") %>
26 |
27 | First commit.
28 |
29 | [Unreleased]: https://github.com/<%= ask("owner") %>/<%= ask("name") %>/compare/0.1.0...HEAD
30 | [keep-a-changelog]: https://github.com/olivierlacan/keep-a-changelog
31 |
32 |
--------------------------------------------------------------------------------
/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-log', function() {
10 | beforeEach(function() {
11 | app = generate();
12 | });
13 |
14 | describe('plugin', function() {
15 | it('should work as a plugin', function() {
16 | app.use(generator);
17 | assert(app.tasks.hasOwnProperty('default'));
18 | assert(app.tasks.hasOwnProperty('changelog'));
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-log') {
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 merge = require('mixin-deep');
9 | var npm = require('npm-install-global');
10 | var del = require('delete');
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, '../templates');
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 | assert(stat);
26 | del(actual(), cb);
27 | });
28 | };
29 | }
30 |
31 | describe('generate-log', function() {
32 | this.slow(250);
33 |
34 | if (!isTravis) {
35 | before(function(cb) {
36 | npm.maybeInstall('generate', cb);
37 | });
38 | }
39 |
40 | beforeEach(function() {
41 | app = generate({silent: true});
42 | app.cwd = actual();
43 | app.option('dest', actual());
44 | app.option('askWhen', 'not-answered');
45 | app.data(require('../package'));
46 | app.data('owner', 'foo');
47 | });
48 |
49 | afterEach(function(cb) {
50 | del(actual(), cb);
51 | });
52 |
53 | describe('plugin', function() {
54 | it('should only register the plugin once', function(cb) {
55 | var count = 0;
56 | app.on('plugin', function(name) {
57 | if (name === 'generate-log') {
58 | count++;
59 | }
60 | });
61 | app.use(generator);
62 | app.use(generator);
63 | app.use(generator);
64 | assert.equal(count, 1);
65 | cb();
66 | });
67 |
68 | it('should extend tasks onto the instance', function() {
69 | app.use(generator);
70 | assert(app.tasks.hasOwnProperty('default'));
71 | assert(app.tasks.hasOwnProperty('changelog'));
72 | });
73 |
74 | it('should run the `default` task with .build', function(cb) {
75 | app.use(generator);
76 | app.build('default', exists(fixtures('changelog.md'), cb));
77 | });
78 |
79 | it('should run the `default` task with .generate', function(cb) {
80 | app.use(generator);
81 | app.generate('default', exists(fixtures('changelog.md'), cb));
82 | });
83 | });
84 |
85 | describe('generator (CLI)', function() {
86 | it('should run the default task using the `generate-log` name', function(cb) {
87 | if (isTravis) return this.skip();
88 | app.use(generator);
89 | app.generate('generate-log', exists(fixtures('changelog.md'), cb));
90 | });
91 |
92 | it('should run the default task using the `generator` generator alias', function(cb) {
93 | if (isTravis) return this.skip();
94 | app.use(generator);
95 | app.generate('changelog', exists(fixtures('changelog.md'), cb));
96 | });
97 | });
98 |
99 | describe('generator (API)', function() {
100 | it('should run the default task on the generator', function(cb) {
101 | app.register('changelog', generator);
102 | app.generate('changelog', exists(fixtures('changelog.md'), cb));
103 | });
104 |
105 | it('should run the `changelog` task', function(cb) {
106 | app.register('changelog', generator);
107 | app.generate('changelog:changelog', exists(fixtures('changelog.md'), cb));
108 | });
109 |
110 | it('should run the `default` task when defined explicitly', function(cb) {
111 | app.register('changelog', generator);
112 | app.generate('changelog:default', exists(fixtures('changelog.md'), cb));
113 | });
114 | });
115 |
116 | describe('sub-generator', function() {
117 | it('should work as a sub-generator', function(cb) {
118 | app.register('foo', function(foo) {
119 | foo.register('changelog', generator);
120 | });
121 | app.generate('foo.changelog', exists(fixtures('changelog.md'), cb));
122 | });
123 |
124 | it('should run the `default` task by default', function(cb) {
125 | app.register('foo', function(foo) {
126 | foo.register('changelog', generator);
127 | });
128 | app.generate('foo.changelog', exists(fixtures('changelog.md'), cb));
129 | });
130 |
131 | it('should run the `changelog:default` task when defined explicitly', function(cb) {
132 | app.register('foo', function(foo) {
133 | foo.register('changelog', generator);
134 | });
135 | app.generate('foo.changelog:default', exists(fixtures('changelog.md'), cb));
136 | });
137 |
138 | it('should run the `changelog:changelog` task', function(cb) {
139 | app.register('foo', function(foo) {
140 | foo.register('changelog', generator);
141 | });
142 | app.generate('foo.changelog:changelog', exists(fixtures('changelog.md'), cb));
143 | });
144 |
145 | it('should work with nested sub-generators', function(cb) {
146 | app
147 | .register('foo', generator)
148 | .register('bar', generator)
149 | .register('baz', generator)
150 |
151 | app.generate('foo.bar.baz', exists(fixtures('changelog.md'), cb));
152 | });
153 | });
154 | });
155 |
--------------------------------------------------------------------------------