Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

Commit

Permalink
add readme template for component-create(1) with more boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Oct 10, 2012
1 parent 1b7ea04 commit 68f68f2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile
@@ -1,4 +1,7 @@

templates/readme.js: templates/readme.md
./node_modules/.bin/minstache < $< > $@

test:
@./node_modules/.bin/mocha \
--require should \
Expand Down
5 changes: 3 additions & 2 deletions bin/component-create
Expand Up @@ -11,7 +11,8 @@ var program = require('commander')
, fs = require('fs')
, join = path.join
, read = fs.readFileSync
, mkdir = require('mkdirp').sync;
, mkdir = require('mkdirp').sync
, readme = require('../templates/readme');

// usage

Expand Down Expand Up @@ -95,7 +96,7 @@ program.prompt({
write(join(dir, 'Makefile'), createMakefile(obj));

// readme
write(join(dir, 'Readme.md'), '\n# ' + name + '\n\n ' + obj.desc + '\n\n');
write(join(dir, 'Readme.md'), readme(obj));

// .gitignore
write(join(dir, '.gitignore'), 'components\nbuild\n');
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -23,6 +23,7 @@
"debug": "*"
},
"devDependencies": {
"minstache": "0.0.1",
"mocha": "*",
"should": "*"
},
Expand Down
20 changes: 20 additions & 0 deletions templates/readme.js
@@ -0,0 +1,20 @@
module.exports = function anonymous(obj) {

function escape(html) {
return String(html)
.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
};

function section(obj, prop, negate, str) {
var val = obj[prop];
if ('function' == typeof val) return val.call(obj, str);
if (negate) val = !val;
if (val) return str;
return '';
};

return "\n# " + escape(obj.name) + "\n\n " + escape(obj.desc) + "\n\n## Installation\n\n $ component install " + escape(obj.repo) + "\n\n## API\n\n \n\n## License\n\n MIT\n"
}
16 changes: 16 additions & 0 deletions templates/readme.md
@@ -0,0 +1,16 @@

# {name}

{desc}

## Installation

$ component install {repo}

## API



## License

MIT

0 comments on commit 68f68f2

Please sign in to comment.