Skip to content

Commit

Permalink
chore: Update to Gulp 4.
Browse files Browse the repository at this point in the history
chore: Updated npm deps.
chore: Added Appveyor config.
chore: Added eslint plugins.
  • Loading branch information
cb1kenobi committed Dec 13, 2018
1 parent a1feb83 commit b1404c4
Show file tree
Hide file tree
Showing 7 changed files with 2,014 additions and 878 deletions.
8 changes: 7 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@
"sourceType": "module"
},
"plugins": [
"chai-expect",
"mocha",
"security"
],
"root": true,
"rules": {
"array-bracket-spacing": [ "error", "always" ],
"array-bracket-spacing": [ "error", "always", { "objectsInArrays": true, "arraysInArrays": true } ],
"brace-style": [ 2, "1tbs", { "allowSingleLine": true } ],
"camelcase": 0,
"chai-expect/missing-assertion": 2,
"chai-expect/terminating-properties": 1,
"curly": [ 2, "all" ],
"eol-last": 2,
"indent": [ 2, "tab", { "SwitchCase": 1 } ],
"keyword-spacing": [ "error" ],
"linebreak-style": [ 2, "unix" ],
"max-len": [ 2, 200 ],
"no-case-declarations": 0,
"no-cond-assign": 0,
"no-console": 0,
"no-control-regex": 0,
"no-empty": 1,
"no-inner-declarations": 0,
"no-mixed-spaces-and-tabs": 2,
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
language: node_js
node_js:
- "6"
- "8"
- "10"
os: linux
sudo: false
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.7.0
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
cache:
yarn: true
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Travis CI Build][travis-image]][travis-url]
[![Appveyor CI Build][appveyor-image]][appveyor-url]
[![Test Coverage][coveralls-image]][coveralls-url]
[![Greenkeeper badge][greenkeeper-image]][greenkeeper-url]
[![Deps][david-image]][david-url]
Expand All @@ -24,7 +25,7 @@ functions such as `JSON.stringify()` work as expected.

## Examples

```javascript
```js
import gawk from 'gawk';

const obj = gawk({
Expand All @@ -43,7 +44,7 @@ console.info(obj); // { foo: 'baz' }

You can also be notified if a deep child is changed:

```javascript
```js
const obj = gawk({
foo: {
bar: ['a', 'b']
Expand All @@ -63,7 +64,7 @@ console.info(obj); // { foo: { bar: ['a', 'b', 'c', 'd'] } }
To filter watch notifications, simply pass in the property name or array of
property names used to filter the gawk object.

```javascript
```js
const obj = gawk({
foo: {
bar: 'hello'
Expand All @@ -79,7 +80,7 @@ obj.foo.bar = 'world!';

To stop watching, simply call `gawk.unwatch()` with the original listener function.

```javascript
```js
const obj = gawk({ /* ... */ });

function onChange(obj, src) {
Expand All @@ -97,7 +98,7 @@ obj.foo = 'baz'; // does not fire onChange()

To update an object and preserve the listeners, you can use the `gawk.set()` function.

```javascript
```js
const obj = gawk({
foo: 'bar'
});
Expand Down Expand Up @@ -251,10 +252,12 @@ MIT
[npm-url]: https://npmjs.org/package/gawk
[downloads-image]: https://img.shields.io/npm/dm/gawk.svg
[downloads-url]: https://npmjs.org/package/gawk
[travis-image]: https://img.shields.io/travis/cb1kenobi/gawk.svg
[travis-image]: https://travis-ci.org/cb1kenobi/gawk.svg?branch=master
[travis-url]: https://travis-ci.org/cb1kenobi/gawk
[coveralls-image]: https://img.shields.io/coveralls/cb1kenobi/gawk/master.svg
[coveralls-url]: https://coveralls.io/r/cb1kenobi/gawk
[appveyor-image]: https://ci.appveyor.com/api/projects/status/1ee7r1drlswy5jk6?svg=true
[appveyor-url]: https://ci.appveyor.com/project/cb1kenobi/gawk
[greenkeeper-image]: https://badges.greenkeeper.io/cb1kenobi/gawk.svg
[greenkeeper-url]: https://greenkeeper.io/
[david-image]: https://img.shields.io/david/cb1kenobi/gawk.svg
Expand Down
19 changes: 19 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
environment:
matrix:
# node.js
- nodejs_version: "10"
- nodejs_version: "8"

install:
- ps: Install-Product node $env:nodejs_version
- yarn

test_script:
- node --version
- yarn --version
- yarn run coverage

build: off

# build version format
version: "{build}"
69 changes: 34 additions & 35 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,40 @@ const manifest = require('./package.json');
const path = require('path');
const spawnSync = require('child_process').spawnSync;

const { parallel, series } = gulp;

const coverageDir = path.join(__dirname, 'coverage');
const distDir = path.join(__dirname, 'dist');
const docsDir = path.join(__dirname, 'docs');
const distDir = path.join(__dirname, 'dist');
const docsDir = path.join(__dirname, 'docs');

/*
* Clean tasks
*/
gulp.task('clean', ['clean-coverage', 'clean-dist', 'clean-docs']);

gulp.task('clean-coverage', cb => fs.remove(coverageDir, cb));
async function cleanCoverage() { return fs.remove(coverageDir); }
async function cleanDist() { return fs.remove(distDir); }
async function cleanDocs() { return fs.remove(docsDir); }
exports.clean = parallel(cleanCoverage, cleanDist, cleanDocs);

gulp.task('clean-dist', cb => fs.remove(distDir, cb));

gulp.task('clean-docs', cb => fs.remove(docsDir, cb));
/*
* lint tasks
*/
async function lint(pattern) {
return gulp.src(pattern)
.pipe($.plumber())
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
}
async function lintSrc() { return lint('src/**/*.js'); }
async function lintTest() { return lint('test/**/test-*.js'); }
exports['lint-src'] = lintSrc;
exports['lint-test'] = lintTest;
exports.lint = parallel(lintSrc, lintTest);

/*
* build tasks
*/
gulp.task('build', ['clean-dist', 'lint-src'], function () {
async function build() {
return gulp
.src('src/**/*.js')
.pipe($.plumber())
Expand All @@ -38,9 +53,11 @@ gulp.task('build', ['clean-dist', 'lint-src'], function () {
}))
.pipe($.sourcemaps.write())
.pipe(gulp.dest(distDir));
});
}
exports.build = series(parallel(cleanDist, lintSrc), build);
exports.default = exports.build;

gulp.task('docs', ['lint-src', 'clean-docs'], () => {
exports.docs = series(parallel(cleanDocs, lintSrc), async () => {
const esdoc = require('esdoc').default;

esdoc.generate({
Expand Down Expand Up @@ -69,30 +86,10 @@ gulp.task('docs', ['lint-src', 'clean-docs'], () => {
});
});

/*
* lint tasks
*/
function lint(pattern) {
return gulp.src(pattern)
.pipe($.plumber())
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
}

gulp.task('lint-src', () => lint('src/**/*.js'));

gulp.task('lint-test', () => lint('test/**/test-*.js'));

/*
* test tasks
*/
gulp.task('test', [ 'build', 'lint-test' ], () => runTests());
gulp.task('test-only', [ 'lint-test' ], () => runTests());
gulp.task('coverage', [ 'clean-coverage', 'lint-src', 'lint-test' ], () => runTests(true));
gulp.task('coverage-only', [ 'clean-coverage', 'lint-test' ], () => runTests(true));

function runTests(cover) {
async function runTests(cover) {
const args = [];
let { execPath } = process;

Expand All @@ -114,7 +111,6 @@ function runTests(cover) {
// https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-reports/lib
'--reporter=html',
'--reporter=json',
'--reporter=lcov',
'--reporter=text',
'--reporter=text-summary',
'--require', path.join(__dirname, 'test', 'transpile.js'),
Expand Down Expand Up @@ -161,7 +157,7 @@ function runTests(cover) {
args.push('test/**/test-*.js');
}

log('Running: ' + ansiColors.cyan(execPath + ' ' + args.join(' ')));
log(`Running: ${ansiColors.cyan(`${execPath} ${args.join(' ')}`)}`);

// run!
if (spawnSync(execPath, args, { stdio: 'inherit' }).status) {
Expand All @@ -188,4 +184,7 @@ function resolveModule(name) {
}
}

gulp.task('default', ['build']);
exports.test = series(parallel(lintTest, build), () => runTests());
exports['test-only'] = series(lintTest, () => runTests());
exports.coverage = series(parallel(cleanCoverage, lintTest, build), () => runTests(true));
exports['coverage-only'] = series(parallel(cleanCoverage, lintTest), () => runTests(true));
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,35 @@
"source-map-support": "^0.5.9"
},
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/plugin-transform-modules-commonjs": "^7.1.0",
"@babel/core": "^7.2.0",
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
"@babel/register": "^7.0.0",
"ansi-colors": "^3.1.0",
"ansi-colors": "^3.2.3",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.4",
"babel-plugin-istanbul": "^5.0.1",
"babel-plugin-istanbul": "^5.1.0",
"chai": "^4.2.0",
"coveralls": "^3.0.2",
"esdoc": "^1.1.0",
"esdoc-ecmascript-proposal-plugin": "^1.0.0",
"esdoc-standard-plugin": "^1.0.0",
"eslint": "^5.6.1",
"eslint": "^5.10.0",
"eslint-plugin-chai-expect": "^2.0.1",
"eslint-plugin-mocha": "^5.2.0",
"eslint-plugin-security": "^1.4.0",
"fancy-log": "^1.3.2",
"fs-extra": "^7.0.0",
"gulp": "^3.9.1",
"fancy-log": "^1.3.3",
"fs-extra": "^7.0.1",
"gulp": "^4.0.0",
"gulp-babel": "^8.0.0",
"gulp-debug": "^4.0.0",
"gulp-eslint": "^5.0.0",
"gulp-load-plugins": "^1.5.0",
"gulp-plumber": "^1.2.0",
"gulp-plumber": "^1.2.1",
"gulp-sourcemaps": "^2.6.4",
"gulp-util": "^3.0.8",
"mocha": "^5.2.0",
"nyc": "^13.0.1",
"sinon": "^6.3.4",
"sinon-chai": "^3.2.0"
"nyc": "^13.1.0",
"sinon": "^7.2.2",
"sinon-chai": "^3.3.0"
},
"homepage": "https://github.com/cb1kenobi/gawk",
"bugs": "https://github.com/cb1kenobi/gawk/issues",
Expand Down
Loading

0 comments on commit b1404c4

Please sign in to comment.