-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add bluebrd, lodash, monet and shelljs
- Loading branch information
Showing
3 changed files
with
96 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,56 @@ | ||
/* eslint quotes: [0, "double"], strict: [0] */ | ||
|
||
"use strict"; | ||
|
||
var shelljs = require("shelljs"); | ||
var promise = require("bluebird"); | ||
var _ = require("lodash"); | ||
var fs = promise.promisifyAll(require("fs")); | ||
var monet = require("monet"); | ||
var path = require("path"); | ||
var $m = monet.Maybe.fromNull; | ||
|
||
var _require = require("docopt"); | ||
|
||
var docopt = _require.docopt; | ||
|
||
function doMaybe(gen) { | ||
"use strict"; | ||
|
||
function step(value) { | ||
var result = gen.next(value); | ||
if (result.done) { | ||
return result.value; | ||
} | ||
return result.value.bind(step); | ||
} | ||
return step(); | ||
} | ||
|
||
var getOption = function (a, b, def, o) { | ||
"use strict"; | ||
return $m(o[a]).orElse($m(o[b])).orSome(def); | ||
}; | ||
|
||
var _module = function () { | ||
var mod = function () { | ||
|
||
var foo = function () {}; | ||
return { | ||
$s: promise.promisifyAll(shelljs), | ||
$b: promise, | ||
Promise: promise, | ||
_: _, | ||
$d: docopt, | ||
$o: getOption, | ||
|
||
return { | ||
foo: foo | ||
}; | ||
$mMaybe: monet.Maybe, | ||
$mDoMaybe: doMaybe, | ||
$m: monet.Maybe.fromNull, | ||
$f: { | ||
readLocal: function (f) { | ||
return fs.readFileAsync(path.join(__dirname, "/" + f), "utf8"); | ||
} | ||
} | ||
}; | ||
}; | ||
|
||
module.exports = _module(); | ||
module.exports = mod(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,54 @@ | ||
var shelljs = require( 'shelljs' ) | ||
var promise = require( 'bluebird' ) | ||
var _ = require( 'lodash' ) | ||
/* eslint quotes: [0, "double"], strict: [0] */ | ||
|
||
var _module = () => { | ||
var shelljs = require('shelljs') | ||
var promise = require('bluebird') | ||
var _ = require('lodash') | ||
var fs = promise.promisifyAll(require('fs')) | ||
var monet = require('monet') | ||
var path = require('path') | ||
var $m = monet.Maybe.fromNull | ||
|
||
var foo = () => { | ||
var { | ||
docopt | ||
} = require('docopt') | ||
|
||
} | ||
function doMaybe(gen) { | ||
"use strict" | ||
|
||
return { | ||
foo | ||
} | ||
function step(value) { | ||
var result = gen.next(value); | ||
if (result.done) { | ||
return result.value; | ||
} | ||
return result.value.bind(step); | ||
} | ||
return step(); | ||
} | ||
|
||
module.exports = _module() | ||
var getOption = (a, b, def, o) => { | ||
"use strict" | ||
return $m(o[a]) | ||
.orElse($m(o[b])) | ||
.orSome(def) | ||
} | ||
|
||
var mod = () => { | ||
|
||
return { | ||
$s: promise.promisifyAll(shelljs), | ||
$b: promise, | ||
Promise: promise, | ||
_: _, | ||
$d: docopt, | ||
$o: getOption, | ||
|
||
$mMaybe: monet.Maybe, | ||
$mDoMaybe: doMaybe, | ||
$m: monet.Maybe.fromNull, | ||
$f: { | ||
readLocal: (f) => fs.readFileAsync(path.join(__dirname, `/${f}`), 'utf8') | ||
} | ||
} | ||
} | ||
|
||
module.exports = mod() |