Permalink
Browse files

Merge branch 'lm01/master'

  • Loading branch information...
MicFin committed May 8, 2017
2 parents 58d750a + e138f1f commit a77985510530550e066ea115be9e2616e0d945e1
Showing with 182 additions and 191 deletions.
  1. +11 −0 .eslintrc.json
  2. +0 −17 .gitignore
  3. +0 −15 .jscsrc
  4. +0 −1 .jshintignore
  5. +0 −15 .jshintrc
  6. +4 −6 Gruntfile.js
  7. +29 −0 bin/add-code-block.js
  8. +8 −8 bin/copy-json.js
  9. +21 −0 bin/example.js
  10. +5 −5 bin/hey-yall.js
  11. +2 −19 bin/index.js
  12. +5 −5 bin/randomizer.js
  13. +4 −3 grunt/aliases.json
  14. +12 −0 grunt/eslint.json
  15. +0 −19 grunt/jscs.json
  16. +0 −8 grunt/jshint.json
  17. +7 −1 grunt/mochacli.json
  18. +16 −16 lib/copy-json.js
  19. +3 −3 lib/example.js
  20. +10 −10 lib/hey-yall.js
  21. +17 −17 lib/randomizer.js
  22. +6 −3 package.json
  23. +5 −0 spec/.eslintrc.json
  24. +17 −20 spec/example.spec.js
@@ -0,0 +1,11 @@
{
"extends": "standard",
"root": true,
"env": {
"node": true
},
"rules": {
"prefer-const": "error",
"no-var": "error"
}
}
@@ -42,57 +42,40 @@ Temporary Items
.nfs*

# End of https://www.gitignore.io/api/macos,linux

# Created by https://www.gitignore.io/api/node

### Node ###
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity


# End of https://www.gitignore.io/api/node
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))
}
}
})
@@ -1,13 +1,13 @@
'use strict';
'use strict'

const copyJson = require('../lib/copy-json.js');
const copyJson = require('../lib/copy-json.js')

const stdin = '/dev/stdin';
const stdout = '/dev/stdout';
const stdin = '/dev/stdin'
const stdout = '/dev/stdout'

let inFile = process.argv[2] === '-' ? stdin : process.argv[2];
let outFile = process.argv[3] ? process.argv[3] : stdout;
const inFile = process.argv[2] === '-' ? stdin : process.argv[2]
const outFile = process.argv[3] ? process.argv[3] : stdout

let outFileFlag = outFile === stdout ? 'a' : 'w';
const outFileFlag = outFile === stdout ? 'a' : 'w'

copyJson(inFile, outFile, outFileFlag);
copyJson(inFile, outFile, outFileFlag)
@@ -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,11 +1,11 @@
'use strict';
'use strict'

const heyYall = require('../lib/hey-yall.js');
const heyYall = require('../lib/hey-yall.js')

const inFile = process.argv[2];
const inFile = process.argv[2]

if (!inFile) {
throw('Script requires one argument, an input file.');
throw new Error('Script requires one argument, an input file.')
}

heyYall(inFile);
heyYall(inFile)
@@ -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,11 +1,11 @@
'use strict';
'use strict'

const randomizer = require('../lib/randomizer.js');
const randomizer = require('../lib/randomizer.js')

let inFile = process.argv[2];
const inFile = process.argv[2]

if (!inFile) {
throw('Script requires one argument, an input file');
throw new Error('Script requires one argument, an input file')
}

randomizer(inFile);
randomizer(inFile)
@@ -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,38 +1,38 @@
'use strict';
'use strict'

const fs = require('fs');
const fs = require('fs')

const copyJson = function (inFile, outFile, outFileFlag) {
fs.readFile(inFile, { encoding: 'utf8' }, (error, data) => {
let json, pojo;
let pojo
if (error) {
console.error(error.stack);
return;
console.error(error.stack)
return
}

// parse the data into JSON
try {
pojo = JSON.parse(data);
pojo = JSON.parse(data)
} catch (error) {
console.error(error.stack);
return;
console.error(error.stack)
return
}

// do something with the pojo

// make a string out of the pojo
json = JSON.stringify(pojo, null, 2);
const json = JSON.stringify(pojo, null, 2)

// save it
fs.writeFile(outFile, json, { flag: outFileFlag }, error => {
if (error) {
console.error(error.stack);
return;
console.error(error.stack)
return
}

console.error('\ncopied');
});
});
};
console.error('\ncopied')
})
})
}

module.exports = copyJson;
module.exports = copyJson
@@ -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)
}
Oops, something went wrong.

0 comments on commit a779855

Please sign in to comment.