├── templates └── _gitattributes ├── index.js ├── docs ├── demo.gif └── demo-dest.gif ├── .gitattributes ├── .travis.yml ├── .editorconfig ├── .gitignore ├── generator.js ├── LICENSE ├── package.json ├── .verb.md ├── .eslintrc.json ├── test.js └── README.md /templates/_gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./generator'); 2 | -------------------------------------------------------------------------------- /docs/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generate/generate-gitattributes/HEAD/docs/demo.gif -------------------------------------------------------------------------------- /docs/demo-dest.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/generate/generate-gitattributes/HEAD/docs/demo-dest.gif -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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-gitattributes')) return; 8 | 9 | /** 10 | * Generates a `.gitattributes` file to the current working directory. The 11 | * built-in template can be [overridden](#customization). 12 | * 13 | * ```sh 14 | * $ gen gitattributes 15 | * ``` 16 | * @name gitattributes 17 | * @api public 18 | */ 19 | 20 | app.task('default', ['gitattributes']); 21 | app.task('gitattributes', function(cb) { 22 | return app.src('templates/_gitattributes', { cwd: __dirname }) 23 | .pipe(app.conflicts(app.cwd)) 24 | .pipe(app.dest(function(file) { 25 | file.basename = '.gitattributes'; 26 | return app.cwd; 27 | })) 28 | }); 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generate-gitattributes", 3 | "description": "Generate a .gitattributes 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.", 4 | "version": "0.1.2", 5 | "homepage": "https://github.com/generate/generate-gitattributes", 6 | "author": "Jon Schlinkert (https://github.com/jonschlinkert)", 7 | "repository": "generate/generate-gitattributes", 8 | "bugs": { 9 | "url": "https://github.com/generate/generate-gitattributes/issues" 10 | }, 11 | "license": "MIT", 12 | "files": [ 13 | "generator.js", 14 | "index.js", 15 | "LICENSE", 16 | "README.md", 17 | "templates" 18 | ], 19 | "main": "index.js", 20 | "engines": { 21 | "node": ">=0.10.0" 22 | }, 23 | "scripts": { 24 | "test": "mocha" 25 | }, 26 | "dependencies": { 27 | "is-valid-app": "^0.2.0" 28 | }, 29 | "devDependencies": { 30 | "delete": "^0.3.2", 31 | "generate": "^0.8.3", 32 | "gulp-format-md": "^0.1.9", 33 | "mocha": "^2.5.3", 34 | "npm-install-global": "^0.1.2" 35 | }, 36 | "keywords": [ 37 | "boilerplate", 38 | "build", 39 | "cli", 40 | "cli-app", 41 | "command-line", 42 | "create", 43 | "dev", 44 | "development", 45 | "framework", 46 | "front", 47 | "frontend", 48 | "generate", 49 | "generate-generator", 50 | "generate-plugin", 51 | "generategenerator", 52 | "generateplugin", 53 | "generator", 54 | "gitattributes", 55 | "init", 56 | "initialize", 57 | "new", 58 | "plugin", 59 | "project", 60 | "projects", 61 | "scaffold", 62 | "scaffolder", 63 | "scaffolding", 64 | "template", 65 | "templates", 66 | "webapp", 67 | "yeoman", 68 | "yo" 69 | ], 70 | "verb": { 71 | "toc": false, 72 | "layout": "generator", 73 | "tasks": [ 74 | "readme" 75 | ], 76 | "plugins": [ 77 | "gulp-format-md" 78 | ], 79 | "reflinks": [ 80 | "assemble", 81 | "base", 82 | "generate", 83 | "generate-dest", 84 | "generate-install", 85 | "gulp", 86 | "verb", 87 | "verb-readme-generator" 88 | ], 89 | "lint": { 90 | "reflinks": true 91 | }, 92 | "related": { 93 | "list": [] 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /.verb.md: -------------------------------------------------------------------------------- 1 | **Example** 2 | 3 | Templates are [customizable](#customization) and can be overridden. 4 | 5 | ![{%= name %} demo](https://raw.githubusercontent.com/{%= repo %}/master/docs/demo.gif) 6 | 7 |
8 |
9 | 10 | ## What is "{%= platform.proper %}"? 11 | {%= include(platform.name + "/what-is-" + platform.name) %} 12 | 13 |
14 |
15 | 16 | ## Command line usage 17 | 18 | ### Install globally 19 | {%= include(platform.name + "/" + platform.configname + "-install") %} 20 | 21 | ### Running {%= name %} 22 | 23 | You should now be able to run `{%= name %}` with the following command: 24 | 25 | ```sh 26 | $ {%= platform.command %} {%= strip(platform.name + '-', name) %} 27 | ``` 28 | 29 | **What will happen?** 30 | 31 | Running `$ gen {%= strip(platform.name + '-', name) %}` will run the generator's [default task](#default), which writes a `.gitattributes` file to the current working directory, or the [specified directory](#customization). 32 | 33 | **What you should see in the terminal** 34 | 35 | If completed successfully, you should see both `starting` and `finished` events in the terminal, like the following: 36 | 37 | ```sh 38 | [00:44:21] starting ... 39 | ... 40 | [00:44:22] finished ✔ 41 | ``` 42 | 43 | If you do not see one or both of those events, please [let us know about it](../../issues). 44 | 45 | ### Help 46 | 47 | To see a general help menu and available commands for {%= platform.proper %}'s CLI, run: 48 | 49 | ```sh 50 | $ {%= platform.command %} help 51 | ``` 52 | 53 | ## Running multiple generators 54 | 55 | [generate][] supports running multiple generators at once. Here is an example of a generator that works well with `{%= name %}`. 56 | 57 | ### generate-dest 58 | 59 | Run [generate-dest][] **before** this generator to prompt for the destination directory to use for generated files. 60 | 61 | **Example** 62 | 63 | ![{%= name %} generate-dest example](https://raw.githubusercontent.com/{%= repo %}/master/docs/demo-dest.gif) 64 | 65 | ## API usage 66 | 67 | Use `{%= name %}` as a [plugin][docs]{plugins.md} in your own [generator][docs]{generators.md}. 68 | 69 | ### Install locally 70 | 71 | {%= include("install-npm", {save: true}) %} 72 | 73 | ### Register as a plugin 74 | 75 | Inside your own [generator][docs]{generators.md}: 76 | 77 | ```js 78 | module.exports = function(app) { 79 | // register {%= name %} as a plugin to add the {%= strip(platform.name + '-', name) %} 80 | // task to your own generator 81 | app.use(require('{%= name %}')); 82 | }; 83 | ``` 84 | 85 | ### Run tasks 86 | 87 | Programmatically run tasks from `{%= name %}`. 88 | 89 | ```js 90 | module.exports = function(app) { 91 | // adds the `{%= strip(platform.name + '-', name) %}` task to your generator 92 | app.use(require('{%= name %}')); 93 | 94 | // run the `{%= strip(platform.name + '-', name) %}` task 95 | app.task('default', '{%= strip(platform.name + "-", name) %}'); 96 | }; 97 | ``` 98 | 99 | Visit the [generator docs][docs]{generators.md} to learn more about creating, installing, using and publishing generators. 100 | 101 |
102 |
103 | 104 | ## Customization 105 | 106 | The following instructions can be used to override settings in `{%= name %}`. Visit the [Generate documentation][docs]{overriding-defaults.md} to learn about other ways to override defaults. 107 | 108 | ### Destination directory 109 | 110 | To customize the destination directory, install [generate-dest][] globally, then in the command line prefix `dest` before any other {%= platform.configname %} names. 111 | 112 | For example, the following will prompt you for the destination path to use, then pass the result to `{%= name %}`: 113 | 114 | ```sh 115 | $ {%= platform.command %} dest {%= strip(platform.name + '-', name) %} 116 | ``` 117 | 118 | ### Overriding templates 119 | 120 | You can override a template by adding a template of the same name to the `templates` directory in user home. For example, to override the `.gitattributes` template, add a template at the following path `~/generate/{%= name %}/templates/.gitattributes`, where `~/` is the user-home directory that `os.homedir()` resolves to on your system. 121 | 122 | 123 | [docs]: {%= platform.docs %}/ 124 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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 generator = require('./'); 11 | var app; 12 | 13 | var cwd = path.resolve.bind(path, __dirname, 'actual'); 14 | 15 | function exists(name, cb) { 16 | return function(err) { 17 | if (err) return cb(err); 18 | var filepath = cwd(name); 19 | fs.stat(filepath, function(err, stat) { 20 | if (err) return cb(err); 21 | assert(stat); 22 | del(path.dirname(filepath), cb); 23 | }); 24 | }; 25 | } 26 | 27 | describe('generate-gitattributes', function() { 28 | if (!process.env.CI && !process.env.TRAVIS) { 29 | before(function(cb) { 30 | npm.maybeInstall('generate', cb); 31 | }); 32 | } 33 | 34 | beforeEach(function() { 35 | app = generate({silent: true}); 36 | app.option('dest', cwd()); 37 | }); 38 | 39 | describe('plugin', function() { 40 | it('should only register the plugin once', function(cb) { 41 | var count = 0; 42 | app.on('plugin', function(name) { 43 | if (name === 'generate-gitattributes') { 44 | count++; 45 | } 46 | }); 47 | app.use(generator); 48 | app.use(generator); 49 | app.use(generator); 50 | assert.equal(count, 1); 51 | cb(); 52 | }); 53 | 54 | it('should extend tasks onto the instance', function() { 55 | app.use(generator); 56 | assert(app.tasks.hasOwnProperty('default')); 57 | assert(app.tasks.hasOwnProperty('gitattributes')); 58 | }); 59 | 60 | it('should run the `default` task with .build', function(cb) { 61 | app.use(generator); 62 | app.build('default', exists('.gitattributes', cb)); 63 | }); 64 | 65 | it('should run the `default` task with .generate', function(cb) { 66 | app.use(generator); 67 | app.generate('default', exists('.gitattributes', cb)); 68 | }); 69 | 70 | it('should run the `gitattributes` task with .build', function(cb) { 71 | app.use(generator); 72 | app.build('gitattributes', exists('.gitattributes', cb)); 73 | }); 74 | 75 | it('should run the `gitattributes` task with .generate', function(cb) { 76 | app.use(generator); 77 | app.generate('gitattributes', exists('.gitattributes', cb)); 78 | }); 79 | }); 80 | 81 | if (!process.env.CI && !process.env.TRAVIS) { 82 | describe('generator (CLI)', function() { 83 | it('should run the default task using the `generate-gitattributes` name', function(cb) { 84 | app.use(generator); 85 | app.generate('generate-gitattributes', exists('.gitattributes', cb)); 86 | }); 87 | 88 | it('should run the default task using the `gitattributes` generator alias', function(cb) { 89 | app.use(generator); 90 | app.generate('gitattributes', exists('.gitattributes', cb)); 91 | }); 92 | }); 93 | } 94 | 95 | describe('generator (API)', function() { 96 | it('should run the default task on the generator', function(cb) { 97 | app.register('gitattributes', generator); 98 | app.generate('gitattributes', exists('.gitattributes', cb)); 99 | }); 100 | 101 | it('should run the `gitattributes` task', function(cb) { 102 | app.register('gitattributes', generator); 103 | app.generate('gitattributes:gitattributes', exists('.gitattributes', cb)); 104 | }); 105 | 106 | it('should run the `default` task when defined explicitly', function(cb) { 107 | app.register('gitattributes', generator); 108 | app.generate('gitattributes:default', exists('.gitattributes', cb)); 109 | }); 110 | }); 111 | 112 | describe('sub-generator', function() { 113 | it('should work as a sub-generator', function(cb) { 114 | app.register('foo', function(foo) { 115 | foo.register('gitattributes', generator); 116 | }); 117 | app.generate('foo.gitattributes', exists('.gitattributes', cb)); 118 | }); 119 | 120 | it('should run the `default` task by default', function(cb) { 121 | app.register('foo', function(foo) { 122 | foo.register('gitattributes', generator); 123 | }); 124 | app.generate('foo.gitattributes', exists('.gitattributes', cb)); 125 | }); 126 | 127 | it('should run the `gitattributes:default` task when defined explicitly', function(cb) { 128 | app.register('foo', function(foo) { 129 | foo.register('gitattributes', generator); 130 | }); 131 | app.generate('foo.gitattributes:default', exists('.gitattributes', cb)); 132 | }); 133 | 134 | it('should run the `gitattributes:gitattributes` task', function(cb) { 135 | app.register('foo', function(foo) { 136 | foo.register('gitattributes', generator); 137 | }); 138 | app.generate('foo.gitattributes:gitattributes', exists('.gitattributes', cb)); 139 | }); 140 | 141 | it('should work with nested sub-generators', function(cb) { 142 | app 143 | .register('foo', generator) 144 | .register('bar', generator) 145 | .register('baz', generator) 146 | 147 | app.generate('foo.bar.baz', exists('.gitattributes', cb)); 148 | }); 149 | }); 150 | }); 151 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | 5 | 6 |

7 | 8 | Generate a .gitattributes 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. 9 | 10 | # generate-gitattributes 11 | 12 | [![NPM version](https://img.shields.io/npm/v/generate-gitattributes.svg?style=flat)](https://www.npmjs.com/package/generate-gitattributes) [![NPM downloads](https://img.shields.io/npm/dm/generate-gitattributes.svg?style=flat)](https://npmjs.org/package/generate-gitattributes) [![Build Status](https://img.shields.io/travis/generate/generate-gitattributes.svg?style=flat)](https://travis-ci.org/generate/generate-gitattributes) 13 | 14 | ![generate-gitattributes demo](https://raw.githubusercontent.com/generate/generate-gitattributes/master/docs/demo.gif) 15 | 16 | **Example** 17 | 18 | Templates are [customizable](#customization) and can be overridden. 19 | 20 | ![generate-gitattributes demo](https://raw.githubusercontent.com/generate/generate-gitattributes/master/docs/demo.gif) 21 | 22 |
23 |
24 | 25 | ## What is "Generate"? 26 | 27 | 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). 28 | 29 | 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. 30 | 31 | **For more information**: 32 | 33 | * Visit the [generate project](https://github.com/generate/generate/) 34 | * Visit the [generate documentation](https://github.com/generate/generate/blob/master/docs/) 35 | * 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)) 36 | 37 |
38 |
39 | 40 | ## Command line usage 41 | 42 | ### Install globally 43 | 44 | **Installing the CLI** 45 | 46 | To run the `gitattributes` 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: 47 | 48 | ```sh 49 | $ npm install --global generate 50 | ``` 51 | 52 | This adds the `gen` command to your system path, allowing it to be run from any directory. 53 | 54 | **Install generate-gitattributes** 55 | 56 | Install this module with the following command: 57 | 58 | ```sh 59 | $ npm install --global generate-gitattributes 60 | ``` 61 | 62 | ### Running generate-gitattributes 63 | 64 | You should now be able to run `generate-gitattributes` with the following command: 65 | 66 | ```sh 67 | $ gen gitattributes 68 | ``` 69 | 70 | **What will happen?** 71 | 72 | Running `$ gen gitattributes` will run the generator's [default task](#default), which writes a `.gitattributes` file to the current working directory, or the [specified directory](#customization). 73 | 74 | **What you should see in the terminal** 75 | 76 | If completed successfully, you should see both `starting` and `finished` events in the terminal, like the following: 77 | 78 | ```sh 79 | [00:44:21] starting ... 80 | ... 81 | [00:44:22] finished ✔ 82 | ``` 83 | 84 | If you do not see one or both of those events, please [let us know about it](../../issues). 85 | 86 | ### Help 87 | 88 | To see a general help menu and available commands for Generate's CLI, run: 89 | 90 | ```sh 91 | $ gen help 92 | ``` 93 | 94 | ## Running multiple generators 95 | 96 | [generate](https://github.com/generate/generate) supports running multiple generators at once. Here is an example of a generator that works well with `generate-gitattributes`. 97 | 98 | ### generate-dest 99 | 100 | Run [generate-dest](https://github.com/generate/generate-dest) **before** this generator to prompt for the destination directory to use for generated files. 101 | 102 | **Example** 103 | 104 | ![generate-gitattributes generate-dest example](https://raw.githubusercontent.com/generate/generate-gitattributes/master/docs/demo-dest.gif) 105 | 106 | ## API usage 107 | 108 | Use `generate-gitattributes` as a [plugin](https://github.com/generate/generate/blob/master/docs/plugins.md) in your own [generator](https://github.com/generate/generate/blob/master/docs/generators.md). 109 | 110 | ### Install locally 111 | 112 | Install with [npm](https://www.npmjs.com/): 113 | 114 | ```sh 115 | $ npm install --save generate-gitattributes 116 | ``` 117 | 118 | ### Register as a plugin 119 | 120 | Inside your own [generator](https://github.com/generate/generate/blob/master/docs/generators.md): 121 | 122 | ```js 123 | module.exports = function(app) { 124 | // register generate-gitattributes as a plugin to add the gitattributes 125 | // task to your own generator 126 | app.use(require('generate-gitattributes')); 127 | }; 128 | ``` 129 | 130 | ### Run tasks 131 | 132 | Programmatically run tasks from `generate-gitattributes`. 133 | 134 | ```js 135 | module.exports = function(app) { 136 | // adds the `gitattributes` task to your generator 137 | app.use(require('generate-gitattributes')); 138 | 139 | // run the `gitattributes` task 140 | app.task('default', 'gitattributes'); 141 | }; 142 | ``` 143 | 144 | Visit the [generator docs](https://github.com/generate/generate/blob/master/docs/generators.md) to learn more about creating, installing, using and publishing generators. 145 | 146 |
147 |
148 | 149 | ## Customization 150 | 151 | The following instructions can be used to override settings in `generate-gitattributes`. Visit the [Generate documentation](https://github.com/generate/generate/blob/master/docs/overriding-defaults.md) to learn about other ways to override defaults. 152 | 153 | ### Destination directory 154 | 155 | To customize the destination directory, install [generate-dest](https://github.com/generate/generate-dest) globally, then in the command line prefix `dest` before any other generator names. 156 | 157 | For example, the following will prompt you for the destination path to use, then pass the result to `generate-gitattributes`: 158 | 159 | ```sh 160 | $ gen dest gitattributes 161 | ``` 162 | 163 | ### Overriding templates 164 | 165 | You can override a template by adding a template of the same name to the `templates` directory in user home. For example, to override the `.gitattributes` template, add a template at the following path `~/generate/generate-gitattributes/templates/.gitattributes`, where `~/` is the user-home directory that `os.homedir()` resolves to on your system. 166 | 167 | ## What is "Generate"? 168 | 169 | 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). 170 | 171 | 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. 172 | 173 | **For more information**: 174 | 175 | * Visit the [generate project](https://github.com/generate/generate/) 176 | * Visit the [generate documentation](https://github.com/generate/generate/blob/master/docs/) 177 | * 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)) 178 | 179 | ## Getting started 180 | 181 | ### Install 182 | 183 | **Installing the CLI** 184 | 185 | To run the `gitattributes` 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: 186 | 187 | ```sh 188 | $ npm install --global generate 189 | ``` 190 | 191 | This adds the `gen` command to your system path, allowing it to be run from any directory. 192 | 193 | **Install generate-gitattributes** 194 | 195 | Install this module with the following command: 196 | 197 | ```sh 198 | $ npm install --global generate-gitattributes 199 | ``` 200 | 201 | ### Usage 202 | 203 | Run this generator's `default` [task](https://github.com/generate/generate/blob/master/docs/tasks.md#default) with the following command: 204 | 205 | ```sh 206 | $ gen gitattributes 207 | ``` 208 | 209 | **What you should see in the terminal** 210 | 211 | If completed successfully, you should see both `starting` and `finished` events in the terminal, like the following: 212 | 213 | ```sh 214 | [00:44:21] starting ... 215 | ... 216 | [00:44:22] finished ✔ 217 | ``` 218 | 219 | If you do not see one or both of those events, please [let us know about it](../../issues). 220 | 221 | ### Help 222 | 223 | To see a general help menu and available commands for Generate's CLI, run: 224 | 225 | ```sh 226 | $ gen help 227 | ``` 228 | 229 | ## Tasks 230 | 231 | All available tasks. 232 | 233 | ### [gitattributes](generator.js#L20) 234 | 235 | Generates a `.gitattributes` file to the current working directory. The built-in template can be [overridden](#customization). 236 | 237 | **Example** 238 | 239 | ```sh 240 | $ gen gitattributes 241 | ``` 242 | 243 | Visit Generate's [documentation for tasks](https://github.com/generate/generate/blob/master/docs/tasks.md). 244 | 245 | ## About 246 | 247 | ### Community 248 | 249 | 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? 250 | 251 | Here are some suggestions! 252 | 253 | * If you get like Generate and want to tweet about it, please feel free to mention `@generatejs` or use the `#generatejs` hashtag 254 | * Show your love by starring [Generate](https://github.com/generate/generate) and `generate-gitattributes` 255 | * Get implementation help on [StackOverflow](http://stackoverflow.com/questions/tagged/generate) (please use the `generatejs` tag in questions) 256 | * **Gitter** Discuss Generate with us on [Gitter](https://gitter.im/generate/generate) 257 | * If you publish an generator, thank you! To make your project as discoverable as possible, please add the keyword `generategenerator` to package.json. 258 | 259 | ### Contributing 260 | 261 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). 262 | 263 | ### Running tests 264 | 265 | Install dev dependencies: 266 | 267 | ```sh 268 | $ npm install -d && npm test 269 | ``` 270 | 271 | ### Author 272 | 273 | **Jon Schlinkert** 274 | 275 | * [github/jonschlinkert](https://github.com/jonschlinkert) 276 | * [twitter/jonschlinkert](http://twitter.com/jonschlinkert) 277 | 278 | ### License 279 | 280 | Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). 281 | Released under the [MIT license](https://github.com/generate/generate-gitattributes/blob/master/LICENSE). 282 | 283 | *** 284 | 285 | _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.30, on August 17, 2016._ --------------------------------------------------------------------------------