Skip to content

Commit

Permalink
chore!: Normalize repository, dropping node <10.13 support (#34)
Browse files Browse the repository at this point in the history
feat: Remove ES5 utility dependencies
chore!: change flatten to Array.prototype.slice.apply

Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
  • Loading branch information
sttk and phated committed Aug 25, 2022
1 parent 0b79fb4 commit 1c631cb
Show file tree
Hide file tree
Showing 25 changed files with 250 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# http://editorconfig.org
# https://editorconfig.org
root = true

[*]
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage/
2 changes: 0 additions & 2 deletions .github/support.yml

This file was deleted.

75 changes: 75 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: dev
on:
pull_request:
push:
branches:
- master
- main
env:
CI: true

jobs:
prettier:
name: Format code
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Prettier
uses: gulpjs/prettier_action@v3.0
with:
commit_message: 'chore: Run prettier'
prettier_options: '--write .'

test:
name: Tests for Node ${{ matrix.node }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
node: [10, 12, 14, 16]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Clone repository
uses: actions/checkout@v2

- name: Set Node.js version
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- run: node --version
- run: npm --version

- name: Install npm dependencies
run: npm install

- name: Run lint
run: npm run lint

- name: Run tests
run: npm test

- name: Coveralls
uses: coverallsapp/github-action@v1.1.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: ${{matrix.os}}-node-${{ matrix.node }}
parallel: true

coveralls:
needs: test
name: Finish up

runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v1.1.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: release
on:
push:
branches:
- master
- main

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: release-please-action
48 changes: 43 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,67 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.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

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
# nyc test coverage
.nyc_output

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

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

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

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# 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

# dotenv environment variables file
.env

# next.js build output
.next

# Garbage files
.DS_Store

# Test results
test.xunit
3 changes: 0 additions & 3 deletions .jscsrc

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage/
.nyc_output/
CHANGELOG.md
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 Blaine Bublitz, Eric Schoffstall and other contributors
Copyright (c) 2014, 2016-2018, 2022 Blaine Bublitz <blaine.bublitz@gmail.com> and Eric Schoffstall <yo@contra.io>.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<p align="center">
<a href="http://gulpjs.com">
<a href="https://gulpjs.com">
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
</a>
</p>

# bach

[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]

Compose your async functions with elegance.

Expand Down Expand Up @@ -231,22 +231,21 @@ Called immediately after a failed function call with the `error` of the function

MIT

[domain]: http://nodejs.org/api/domain.html
[async-done]: https://github.com/gulpjs/async-done
[completions]: https://github.com/gulpjs/async-done#completion-and-error-resolution

[downloads-image]: http://img.shields.io/npm/dm/bach.svg
<!-- prettier-ignore-start -->
[downloads-image]: https://img.shields.io/npm/dm/bach.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/bach
[npm-image]: http://img.shields.io/npm/v/bach.svg

[travis-url]: https://travis-ci.org/gulpjs/bach
[travis-image]: http://img.shields.io/travis/gulpjs/bach.svg?label=travis-ci
[npm-image]: https://img.shields.io/npm/v/bach.svg?style=flat-square

[appveyor-url]: https://ci.appveyor.com/project/gulpjs/bach
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/bach.svg?label=appveyor
[ci-url]: https://github.com/gulpjs/bach/actions?query=workflow:dev
[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/bach/dev?style=flat-square

[coveralls-url]: https://coveralls.io/r/gulpjs/bach
[coveralls-image]: http://img.shields.io/coveralls/gulpjs/bach.svg
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/bach.svg?style=flat-square
<!-- prettier-ignore-end -->

<!-- prettier-ignore-start -->
[domain]: https://nodejs.org/api/domain.html
[async-done]: https://github.com/gulpjs/async-done
[completions]: https://github.com/gulpjs/async-done#completion-and-error-resolution
<!-- prettier-ignore-end -->

[gitter-url]: https://gitter.im/gulpjs/gulp
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg
25 changes: 0 additions & 25 deletions appveyor.yml

This file was deleted.

54 changes: 29 additions & 25 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

var assert = require('assert');

var filter = require('arr-filter');
var map = require('arr-map');
var flatten = require('arr-flatten');
var forEach = require('array-each');

function noop() {}

function getExtensions(lastArg) {
Expand All @@ -23,6 +18,10 @@ function filterError(elem) {
return elem.state === 'error';
}

function pluckValue(elem) {
return elem.value;
}

function buildOnSettled(done) {
if (typeof done !== 'function') {
done = noop;
Expand All @@ -33,17 +32,21 @@ function buildOnSettled(done) {
return done(error, null);
}

var settledErrors = filter(result, filterError);
var settledResults = filter(result, filterSuccess);
if (!Array.isArray(result)) {
result = [];
}

var settledErrors = result.filter(filterError);
var settledResults = result.filter(filterSuccess);

var errors = null;
if (settledErrors.length) {
errors = map(settledErrors, 'value');
errors = settledErrors.map(pluckValue);
}

var results = null;
if (settledResults.length) {
results = map(settledResults, 'value');
results = settledResults.map(pluckValue);
}

done(errors, results);
Expand All @@ -53,28 +56,29 @@ function buildOnSettled(done) {
}

function verifyArguments(args) {
args = flatten(args);
var lastIdx = args.length - 1;
args = Array.prototype.slice.apply(args);

assert.ok(args.length, 'A set of functions to combine is required');

forEach(args, function(arg, argIdx) {
var isFunction = typeof arg === 'function';
if (isFunction) {
return;
}
args.forEach(verifyEachArg);

if (argIdx === lastIdx) {
// Last arg can be an object of extension points
return;
}
return args;
}

function verifyEachArg(arg, argIdx, args) {
var isFunction = typeof arg === 'function';
if (isFunction) {
return;
}

var msg = 'Only functions can be combined, got ' + typeof arg +
' for argument ' + argIdx;
assert.ok(isFunction, msg);
});
if (argIdx === args.length - 1) {
// Last arg can be an object of extension points
return;
}

return args;
var msg = 'Only functions can be combined, got ' + typeof arg +
' for argument ' + argIdx;
assert.ok(isFunction, msg);
}

module.exports = {
Expand Down
7 changes: 3 additions & 4 deletions lib/parallel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

var initial = require('array-initial');
var last = require('array-last');
var asyncDone = require('async-done');
var nowAndLater = require('now-and-later');

Expand All @@ -14,10 +12,11 @@ function iterator(fn, key, cb) {
function buildParallel() {
var args = helpers.verifyArguments(arguments);

var extensions = helpers.getExtensions(last(args));
// TODO: use `.at(-1)` when the API is available
var extensions = helpers.getExtensions(args.slice(-1)[0]);

if (extensions) {
args = initial(args);
args = args.slice(0, -1);
}

function parallel(done) {
Expand Down

0 comments on commit 1c631cb

Please sign in to comment.