Skip to content

Commit

Permalink
feat: Integrate prettier into the build process
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Hall committed Mar 16, 2020
1 parent aaeed2f commit 6e7e36c
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 216 deletions.
195 changes: 1 addition & 194 deletions .eslintrc.yml

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .nycrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
all: true
reporter:
- "lcov"
exclude:
- "database/build.js"
- "lib/routemap.js"
- "coverage/**"
- "test/**"
- "app.js"
4 changes: 4 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tabWidth: 4
bracketSpacing: false
printWidth: 80
arrowParens: avoid
10 changes: 5 additions & 5 deletions dist/promisify.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ exports.promisify = promisify;
var customArgumentsToken = "__ES6-PROMISIFY--CUSTOM-ARGUMENTS__";
/**
* promisify()
* Transforms callback-based function -- func(arg1, arg2 .. argN, callback) -- into
* an ES6-compatible Promise. Promisify provides a default callback of the form (error, result)
* and rejects when `error` is truthy.
* Transforms callback-based function -- func(arg1, arg2 .. argN, callback) --
* into an ES6-compatible Promise. Promisify provides a default callback of the
* form (error, result) and rejects when `error` is truthy.
*
* @param {function} original - The function to promisify
* @return {function} A promisified version of `original`
Expand All @@ -24,8 +24,8 @@ function promisify(original) {
} // If the user has asked us to decode argument names for them, honour that


var argumentNames = original[customArgumentsToken]; // If the user has supplied a custom Promise implementation, use it. Otherwise
// fall back to whatever we can find on the global object.
var argumentNames = original[customArgumentsToken]; // If the user has supplied a custom Promise implementation, use it.
// Otherwise fall back to whatever we can find on the global object.

var ES6Promise = promisify.Promise || Promise; // If we can find no Promise implemention, then fail now.

Expand Down
3 changes: 0 additions & 3 deletions lib/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
parserOptions:
sourceType: module

env:
commonjs: false
19 changes: 9 additions & 10 deletions lib/promisify.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ const customArgumentsToken = "__ES6-PROMISIFY--CUSTOM-ARGUMENTS__";

/**
* promisify()
* Transforms callback-based function -- func(arg1, arg2 .. argN, callback) -- into
* an ES6-compatible Promise. Promisify provides a default callback of the form (error, result)
* and rejects when `error` is truthy.
* Transforms callback-based function -- func(arg1, arg2 .. argN, callback) --
* into an ES6-compatible Promise. Promisify provides a default callback of the
* form (error, result) and rejects when `error` is truthy.
*
* @param {function} original - The function to promisify
* @return {function} A promisified version of `original`
*/
function promisify(original) {

// Ensure the argument is a function
if (typeof original !== "function") {
throw new TypeError("Argument to promisify must be a function");
Expand All @@ -21,21 +20,21 @@ function promisify(original) {
// If the user has asked us to decode argument names for them, honour that
const argumentNames = original[customArgumentsToken];

// If the user has supplied a custom Promise implementation, use it. Otherwise
// fall back to whatever we can find on the global object.
// If the user has supplied a custom Promise implementation, use it.
// Otherwise fall back to whatever we can find on the global object.
const ES6Promise = promisify.Promise || Promise;

// If we can find no Promise implemention, then fail now.
if (typeof ES6Promise !== "function") {
throw new Error("No Promise implementation found; do you need a polyfill?");
throw new Error(
"No Promise implementation found; do you need a polyfill?"
);
}

return function (...args) {
return function(...args) {
return new ES6Promise((resolve, reject) => {

// Append the callback bound to the context
args.push(function callback(err, ...values) {

if (err) {
return reject(err);
}
Expand Down
30 changes: 30 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"license": "MIT",
"dependencies": {},
"scripts": {
"pretest": "./node_modules/.bin/eslint 'lib/*.js' 'test/*.js'",
"build": "./node_modules/.bin/babel lib -d dist",
"real-test": "./node_modules/.bin/tape test",
"pretest": "eslint 'lib/*.js' 'test/*.js'",
"build": "babel lib -d dist",
"real-test": "tape test",
"test": "npm run build && npm run real-test",
"test:cover": "npm run build && ./node_modules/.bin/nyc --reporter=lcov --all npm run real-test"
"test:cover": "npm run build && nyc tape test"
},
"bugs": "http://github.com/digitaldesignlabs/es6-promisify/issues",
"files": [
Expand All @@ -30,9 +30,11 @@
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.7",
"@babel/preset-env": "^7.8.7",
"@puntt/eslint-config": "0.0.2",
"es6-promise": "^4.2.8",
"eslint": "^6.8.0",
"nyc": "^15.0.0",
"prettier": "^1.19.1",
"sinon": "^9.0.1",
"tape": "^4.13.2"
}
Expand Down

0 comments on commit 6e7e36c

Please sign in to comment.