Skip to content
This repository
Browse code

add readme template for component-create(1) with more boilerplate

  • Loading branch information...
commit 68f68f2299920af4288c322a4da09aad3df7a858 1 parent 1b7ea04
TJ Holowaychuk authored October 10, 2012
3  Makefile
... ...
@@ -1,4 +1,7 @@
1 1
 
  2
+templates/readme.js: templates/readme.md
  3
+	./node_modules/.bin/minstache < $< > $@
  4
+
2 5
 test:
3 6
 	@./node_modules/.bin/mocha \
4 7
 		--require should \
5  bin/component-create
@@ -11,7 +11,8 @@ var program = require('commander')
11 11
   , fs = require('fs')
12 12
   , join = path.join
13 13
   , read = fs.readFileSync
14  
-  , mkdir = require('mkdirp').sync;
  14
+  , mkdir = require('mkdirp').sync
  15
+  , readme = require('../templates/readme');
15 16
 
16 17
 // usage
17 18
 
@@ -95,7 +96,7 @@ program.prompt({
95 96
   write(join(dir, 'Makefile'), createMakefile(obj));
96 97
 
97 98
   // readme
98  
-  write(join(dir, 'Readme.md'), '\n# ' + name + '\n\n  ' + obj.desc + '\n\n');
  99
+  write(join(dir, 'Readme.md'), readme(obj));
99 100
 
100 101
   // .gitignore
101 102
   write(join(dir, '.gitignore'), 'components\nbuild\n');
1  package.json
@@ -23,6 +23,7 @@
23 23
     "debug": "*"
24 24
   },
25 25
   "devDependencies": {
  26
+    "minstache": "0.0.1",
26 27
     "mocha": "*",
27 28
     "should": "*"
28 29
   },
20  templates/readme.js
... ...
@@ -0,0 +1,20 @@
  1
+module.exports = function anonymous(obj) {
  2
+
  3
+  function escape(html) {
  4
+    return String(html)
  5
+      .replace(/&/g, '&amp;')
  6
+      .replace(/"/g, '&quot;')
  7
+      .replace(/</g, '&lt;')
  8
+      .replace(/>/g, '&gt;');
  9
+  };
  10
+
  11
+  function section(obj, prop, negate, str) {
  12
+    var val = obj[prop];
  13
+    if ('function' == typeof val) return val.call(obj, str);
  14
+    if (negate) val = !val;
  15
+    if (val) return str;
  16
+    return '';
  17
+  };
  18
+
  19
+  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"
  20
+}
16  templates/readme.md
Source Rendered
... ...
@@ -0,0 +1,16 @@
  1
+
  2
+# {name}
  3
+
  4
+  {desc}
  5
+
  6
+## Installation
  7
+
  8
+    $ component install {repo}
  9
+
  10
+## API
  11
+
  12
+   
  13
+
  14
+## License
  15
+
  16
+  MIT

0 notes on commit 68f68f2

Please sign in to comment.
Something went wrong with that request. Please try again.