Permalink
Browse files

Add tests and ci

  • Loading branch information...
1 parent 703a950 commit ab2f7c1e9955693af4de7368fe419509f809ebf5 @mayankchd mayankchd committed Feb 9, 2016
Showing with 43 additions and 4 deletions.
  1. +6 −0 .travis.yml
  2. +8 −2 bin/init.js
  3. +9 −2 package.json
  4. +20 −0 tests/test.js
View
@@ -0,0 +1,6 @@
+language: node_js
+node_js:
+ - '5'
+ - '4'
+before_install:
+- 'npm install -g npm@latest'
View
@@ -9,7 +9,7 @@ require('shelljs/global');
program
.description('Create a MERN app in current directory!')
-.option('-i, --init [type]', 'Init a new mern boilerplate')
+.option('-i, --init [name]', 'Init a new mern boilerplate')
.parse(process.argv);
@@ -18,6 +18,12 @@ if (!which('git')) {
exit(1);
}
+if(! program.init) {
+ console.log(chalk.cyan('Please pass correct options or type --help or -h for help!'));
+ exit(1);
+}
+
+
if(program.init && program.init !== true) {
if(test('-d', program.init)) {
console.log(chalk.red(program.init+ ' already exits! Please choose some another name!!!'));
@@ -30,7 +36,7 @@ if(program.init && program.init !== true) {
exec('git init');
var interval = setInterval(function() {
- logUpdate("Fetching the boilerplate..." + chalk.cyan.bold.dim(frame()));
+ logUpdate("Fetching the boilerplate..." + chalk.cyan.bold(frame()));
}, 50)
var e = exec('git pull https://github.com/Hashnode/mern-starter.git', function(code, stdout, stderr) {
View
@@ -1,10 +1,13 @@
{
"name": "mern-cli",
- "version": "1.0.0",
+ "version": "1.0.1",
"description": "A cli for generating MERN boilerplate",
"main": "index.js",
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
+ "test": "ava tests/*.js"
+ },
+ "engines": {
+ "node": ">=4"
},
"repository": {
"type": "git",
@@ -29,5 +32,9 @@
"elegant-spinner": "^1.0.1",
"log-update": "^1.0.2",
"shelljs": "^0.6.0"
+ },
+ "devDependencies": {
+ "ava": "^0.11.0",
+ "pify": "^2.3.0"
}
}
View
@@ -0,0 +1,20 @@
+import test from 'ava';
+import path from 'path';
+import childProcess from 'child_process';
+import pify from 'pify';
+
+const exec = pify(childProcess.exec);
+
+
+test('shows help on --help', async t => {
+ const stdout = await exec('../bin/init.js --help');
+ t.is(stdout.trim(), 'Usage: init [options]\n\n Create a MERN app in current directory!\n\n Options:\n\n -h, --help output usage information\n -i, --init [type] Init a new mern boilerplate');
+});
+
+
+test('shows help on --h', async t => {
+ const stdout = await exec('../bin/init.js --help');
+ t.is(stdout.trim(), 'Usage: init [options]\n\n Create a MERN app in current directory!\n\n Options:\n\n -h, --help output usage information\n -i, --init [type] Init a new mern boilerplate');
+});
+
+

0 comments on commit ab2f7c1

Please sign in to comment.