Permalink
Browse files

Updates from node-template

Refresh for cohort lm01
  • Loading branch information...
payne-chris-r
payne-chris-r committed May 1, 2017
1 parent 58d750a commit 8c4d6a21fa7f87d7538c71a7254bdab2a15577bd
Showing with 121 additions and 113 deletions.
  1. +11 −0 .eslintrc.json
  2. +0 −15 .jscsrc
  3. +0 −1 .jshintignore
  4. +0 −15 .jshintrc
  5. +4 −6 Gruntfile.js
  6. +29 −0 bin/add-code-block.js
  7. +21 −0 bin/example.js
  8. +2 −19 bin/index.js
  9. +4 −3 grunt/aliases.json
  10. +12 −0 grunt/eslint.json
  11. +0 −19 grunt/jscs.json
  12. +0 −8 grunt/jshint.json
  13. +7 −1 grunt/mochacli.json
  14. +3 −3 lib/example.js
  15. +6 −3 package.json
  16. +5 −0 spec/.eslintrc.json
  17. +17 −20 spec/example.spec.js
@@ -0,0 +1,11 @@
{
"extends": "standard",
"root": true,
"env": {
"node": true
},
"rules": {
"prefer-const": "error",
"no-var": "error"
}
}
15 .jscsrc

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -1,12 +1,10 @@
'use strict';
'use strict'

// http://ericnish.io/blog/how-to-neatly-separate-grunt-files
// http://www.html5rocks.com/en/tutorials/tooling/supercharging-your-gruntfile/
// discuss how to break up gruntfiles

module.exports = function (grunt) {

require('time-grunt')(grunt);
require('load-grunt-config')(grunt);

};
require('time-grunt')(grunt)
require('load-grunt-config')(grunt)
}
@@ -0,0 +1,29 @@
#!/usr/bin/env node
'use strict'
const readline = require('readline')
const fs = require('fs')
const path = require('path')

const outfile = process.stdout

const rl = readline.createInterface({
input: fs.createReadStream(process.argv[2])
})

let inCodeBlock = false

rl.on('line', (line) => {
if (inCodeBlock) {
inCodeBlock = !/<!-- end code block -->/.test(line)
if (!inCodeBlock) outfile.write('```\n' + `${line}\n`)
} else {
outfile.write(`${line}\n`)
inCodeBlock = /<!-- start code block .+ -->/.test(line)
if (inCodeBlock) {
const filename = line.match(/ +file="(.+)" +/)[1]
const extension = path.extname(filename).slice(1)
outfile.write('```' + `${extension}\n`)
outfile.write(fs.readFileSync(filename))
}
}
})
@@ -0,0 +1,21 @@
#!/usr/bin/env node
'use strict'

const example = require('../lib/example')

const success = (data) => console.log('data', data)
const failure = (error) => console.error('error', error)

success(example.sync(false))

example.async(false, (error, data) => {
if (error) {
failure(error)
} else {
success(data)
}
})

example.promise(false)
.then(success)
.catch(failure)
@@ -1,21 +1,4 @@
#!/usr/bin/env node
'use strict';
'use strict'

const example = require('../lib/example');

const success = (data) => console.log('data', data);
const failure = (error) => console.error('error', error);

success(example.sync(false));

example.async(false, (error, data) => {
if (error) {
failure(error);
} else {
success(data);
}
});

example.promise(false)
.then(success)
.catch(failure);
console.log('starting server')
@@ -1,7 +1,8 @@
{
"default": ["nag", "test"],
"nag": ["jshint", "jsonlint:all", "jscs:status"],
"reformat": ["jscs:write"],
"test-watcher": ["mochacli:watch"],
"make-standard": ["eslint:fix"],
"nag": ["eslint:all", "jsonlint:all"],
"server": ["nodemon:server"],
"test": ["mochacli:all"]
"test": ["mochacli:test"]
}
@@ -0,0 +1,12 @@
{
"all": {
"src": ["<%= paths.src.all %>"]
},

"fix": {
"src": ["<%= paths.src.all %>"],
"options": {
"fix": true
}
}
}

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -1,5 +1,11 @@
{
"options": {
"files": ["<%= paths.src.spec %>"]
},
"all": ["<%= paths.src.spec %> "]
"test": {},
"watch": {
"options": {
"flags": ["--watch"]
}
}
}
@@ -1,7 +1,7 @@
'use strict';
'use strict'

module.exports = {
sync: (value) => value,
async: (value, cb) => setTimeout(() => cb(null, value), 0),
promise: (value) => Promise.resolve(value),
};
promise: (value) => Promise.resolve(value)
}
@@ -1,6 +1,6 @@
{
"name": "ga-wdi-boston.node-api-promises",
"version": "0.1.0",
"version": "0.2.0",
"private": true,
"scripts": {
"start": "node bin/index.js"
@@ -13,10 +13,13 @@
"devDependencies": {
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"eslint": "^3.15.0",
"eslint-config-standard": "^6.2.1",
"eslint-plugin-promise": "^3.4.1",
"eslint-plugin-standard": "^2.0.1",
"grunt": "^1.0.1",
"grunt-concurrent": "^2.3.1",
"grunt-contrib-jshint": "^1.1.0",
"grunt-jscs": "^3.0.1",
"grunt-eslint": "^19.0.0",
"grunt-jsonlint": "^1.1.0",
"grunt-mocha-cli": "^3.0.0",
"grunt-nodemon": "^0.4.2",
@@ -0,0 +1,5 @@
{
"env": {
"mocha": true
}
}
@@ -1,37 +1,34 @@
'use strict';
'use strict'

// Allow chai syntax like `expect(foo).to.be.ok;`
// jshint -W030
const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')

const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised)

chai.use(chaiAsPromised);
const expect = chai.expect

const expect = chai.expect;

const example = require('../lib/example');
const example = require('../lib/example')

describe('Sync', function () {
it('is true', function () {
expect(example.sync(true)).to.be.true;
});
});
expect(example.sync(true)).to.be.true
})
})

describe('Async', function () {
it('is true', function (done) {
example.async(true, function (error, value) {
if (error || value !== true) {
error = error || new Error(`value is ${value}`);
error = error || new Error(`value is ${value}`)
}

done(error);
});
});
});
done(error)
})
})
})

describe('Promise', function () {
it('is true', function () {
return expect(example.promise(true)).to.eventually.be.true;
});
});
return expect(example.promise(true)).to.eventually.be.true
})
})

0 comments on commit 8c4d6a2

Please sign in to comment.