Skip to content

Commit

Permalink
添加默认的 cmd 模板, fix #8
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Jun 18, 2013
1 parent 65bcc05 commit ab900cf
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
5 changes: 4 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# History

## 0.4.7

- [improved] [#8](https://github.com/spmjs/spm-init/issues/8) 添加默认的 cmd 模板。

## 0.4.6

Expand Down Expand Up @@ -63,4 +66,4 @@

## 0.1.0

First version
First version
14 changes: 11 additions & 3 deletions bin/spm-init
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ helper.mkInitDir();

var templates = helper.availableTemplates();

/*
/*/
commander init
*/

Expand Down Expand Up @@ -60,8 +60,16 @@ if (!manage(commander)) return;
show help
*/

var cmd = commander.args[0];
if (!cmd || !templates[cmd]) {
var cmd;

if (!commander.args[0]) {
cmd = 'cmd';
console.log(color.green(' Choosing "' + cmd + '" as defaute template.'));
} else {
cmd = commander.args[0];
}

if (!templates[cmd]) {
// argu not exist
if (cmd) {
console.log();
Expand Down
6 changes: 5 additions & 1 deletion index.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"cmd": {
"repo": "spmjs/template-cdm",
"description": "Create a CMD module"
},
"arale": {
"repo": "aralejs/template-arale",
"description": "Create Arale module"
Expand Down Expand Up @@ -35,4 +39,4 @@
"repo": "popomore/grunt-init-command",
"description": "Commonjs template for command "
}
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spm-init",
"version": "0.4.6",
"version": "0.4.7",
"description": "spm init plugin",
"keywords": [
"spm",
Expand Down Expand Up @@ -35,4 +35,4 @@
"bin": {
"spm-init": "bin/spm-init"
}
}
}
16 changes: 16 additions & 0 deletions scripts/post-install.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env node

var spmrc = require('spmrc');
var spawn = require('win-spawn');
var fs = require('fs');

try {
var spm = require('spm');
spm.plugin.install({
Expand All @@ -15,3 +19,15 @@ try {
console.log(" if you have installed spm, it maybe you haven't set a NODE_PATH environment variable");
console.log();
}

// install spm-init templates
gitInstall('git://github.com/spmjs/template-cmd.git', '~/.spm/init/cmd');

function gitInstall(url, dest) {
dest = dest.replace('~', spmrc.get('user.home'));
if (!fs.existsSync(dest)) {
spawn('git', ['clone', url, dest], {stdio: 'inherit'});
} else {
spawn('git', ['pull', 'origin', 'master'], {stdio: 'inherit', 'cwd': dest});
}
}

0 comments on commit ab900cf

Please sign in to comment.