Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions swaintek/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
7 changes: 7 additions & 0 deletions swaintek/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const greet = module.exports = function() {
return `HI ${process.argv[2] || 'Dave'}`;
};

console.log(greet());
23 changes: 23 additions & 0 deletions swaintek/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var gulp = require ('gulp');
var mocha = require('gulp-mocha');
var eslint = require('gulp-eslint')

gulp.task('mocha', function () {
return gulp.src(['test/greet_test.js'], {read: false})
.pipe(mocha());
});

gulp.task('lint', function () {
return gulp.src(['**/*.js', '!node_modules'])
.pipe(eslint({
rules: {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add something like this to your call to eslint to fix ES lint errors:
.pipe(eslint({
parserOptions: {
"ecmaVersion": 6
}...

'no-var': 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw you getting warning for using var - good job there. You might want to add something to clean up the ES6 linter errors.

}
}))
.pipe(eslint.format());
});

gulp.task('default', ['mocha', 'lint'], function () {
gulp.watch(['test/greet_test.js'], ['mocha']);
gulp.watch(['**/*.js'], ['lint']);
});
24 changes: 24 additions & 0 deletions swaintek/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "greet",
"version": "1.0.0",
"description": "",
"main": "greet.js",
"directories": {
"test": "test"
},
"dependencies": {
"chai": "^3.5.0",
"eslint": "^2.9.0",
"gulp": "^3.9.1",
"gulp-eslint": "^2.0.0",
"gulp-mocha": "^2.2.0"
},
"devDependencies": {
"mocha": "^2.4.5"
},
"scripts": {
"test": "mocha"
},
"author": "",
"license": "ISC"
}
15 changes: 15 additions & 0 deletions swaintek/test/greet_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'
const expect = require('chai').expect;
const greet = require('../greet');

describe('greet tests', () => {
it('should greet Dave by default', () => {
expect(greet()).to.eql('HI Dave');
})
it('should greet from process', () => {
let backupProcess = process.argv;
process.argv = ['node', 'test_path', 'test'];
expect(greet()).to.eql('HI test');
process.argv = backupProcess;
})
})