Skip to content

Commit

Permalink
use nyc, update eslint, update old deps (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcriffey committed May 22, 2017
1 parent 8a31c34 commit b81c4af
Show file tree
Hide file tree
Showing 24 changed files with 82 additions and 73 deletions.
7 changes: 5 additions & 2 deletions .babelrc
@@ -1,3 +1,6 @@
{
"presets": ["es2015"]
}
"presets": ["es2015"],
"env": {
"test": { "plugins": ["istanbul"] }
}
}
9 changes: 5 additions & 4 deletions .eslintrc
@@ -1,5 +1,6 @@
---
"extends":
- "defaults/configurations/walmart/es6"
"env":
"node": true
extends:
- formidable/configurations/es6-node-test

parserOptions:
sourceType: module
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
.nyc_output/
coverage/
lib/
node_modules/
Expand Down
18 changes: 0 additions & 18 deletions .istanbul.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .nycrc
@@ -0,0 +1,20 @@
{
"all": true,
"branches": 100,
"functions": 100,
"include": ["src/*.js"],
"lines": 100,
"instrument": false,
"reporter": [
"lcov",
"html",
"text",
"text-summary"
],
"require": [
"babel-register",
"./test/main"
],
"statements": 100,
"sourceMap": false
}
6 changes: 2 additions & 4 deletions .travis.yml
@@ -1,10 +1,8 @@
language: node_js

node_js:
- "0.12"
- "4.4"
- "5.12"
- "6.2"
- "4"
- "6"

sudo: false

Expand Down
27 changes: 14 additions & 13 deletions package.json
Expand Up @@ -7,15 +7,13 @@
},
"scripts": {
"build": "rimraf lib && babel src/ -d lib/",
"check-coverage": "babel-istanbul check-coverage",
"cover": "rimraf coverage && NODE_PATH=src babel-node node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha -- --require test/main.js --recursive test",
"coverage": "rimraf coverage && NODE_PATH=src NODE_ENV=test nyc --check-coverage mocha 'test/**/*.spec.js'",
"dry-run": "node bin/publishr.js dry-run",
"lint": "eslint bin src test",
"test": "npm run lint && npm run cover && npm run check-coverage",
"test": "npm run lint && npm run coverage",
"postinstall": "cd lib || npm run build",
"postpublish": "node bin/publishr.js postpublish",
"postversion": "npm run build && node bin/publishr.js postversion",
"unit": "NODE_PATH=src babel-node node_modules/.bin/_mocha --require test/main.js --recursive test"
"postversion": "npm run build && node bin/publishr.js postversion"
},
"repository": {
"type": "git",
Expand All @@ -31,25 +29,28 @@
"dependencies": {
"babel-cli": "^6.9.1",
"babel-core": "^6.9.1",
"babel-register": "^6.9.1",
"babel-plugin-istanbul": "^4.1.1",
"babel-preset-es2015": "^6.9.0",
"chalk": "^1.1.3",
"es6-promise": "^3.2.1",
"log-symbols": "^1.0.2",
"mock-fs": "^3.9.0",
"mock-fs": "^4.0.0",
"object-assign": "^4.1.0",
"rimraf": "^2.5.2",
"yargs": "^4.7.1"
},
"devDependencies": {
"babel-eslint": "^6.0.4",
"babel-istanbul": "^0.8.0",
"babel-eslint": "^7.0.0",
"chai": "^3.5.0",
"coveralls": "^2.11.9",
"eslint": "^1.0.0",
"eslint-config-defaults": "^9.0.0",
"eslint-plugin-filenames": "^0.2.0",
"mocha": "^2.5.3",
"sinon": "^1.17.4",
"eslint": "^2.0.0",
"eslint-config-formidable": "^2.0.0",
"eslint-plugin-filenames": "^1.0.0",
"eslint-plugin-import": "^2.0.0",
"mocha": "^3.0.0",
"nyc": "^10.0.0",
"sinon": "^2.0.0",
"sinon-chai": "^2.8.0"
},
"publishr": {
Expand Down
2 changes: 1 addition & 1 deletion src/args.js
Expand Up @@ -4,7 +4,7 @@ import yargs from "yargs";
const args = {
init() {
return yargs
.usage(`Usage: publishr <command> [options]`)
.usage("Usage: publishr <command> [options]")
.command("dry-run", "Perform a dry run of postversion and postpublish")
.command("postpublish", "Clean up any actions taken by postversion")
.command("postversion", "Create and overwrite files for publishing")
Expand Down
1 change: 1 addition & 0 deletions src/constants.js
@@ -0,0 +1 @@
export const NUM_JSON_SPACES = 2;
7 changes: 4 additions & 3 deletions src/dry-runner.js
@@ -1,4 +1,5 @@
import {Promise} from "es6-promise";
import { Promise } from "es6-promise";
import { NUM_JSON_SPACES } from "./constants";
import fileUtils from "./file-utils";
import git from "./git";
import logger from "./logger";
Expand Down Expand Up @@ -34,7 +35,7 @@ const dryRunner = {
},

patchFileSystem(packageJSON, files) {
mockfs = require("mock-fs");
mockfs = require("mock-fs"); // eslint-disable-line global-require

const fileSystem = files.reduce((result, file) => {
result[file.path] = mockfs.file({
Expand All @@ -44,7 +45,7 @@ const dryRunner = {

return result;
}, {
"package.json": JSON.stringify(packageJSON, null, 2)
"package.json": JSON.stringify(packageJSON, null, NUM_JSON_SPACES)
});

mockfs(fileSystem);
Expand Down
2 changes: 1 addition & 1 deletion src/file-handler.js
@@ -1,4 +1,4 @@
import {Promise} from "es6-promise";
import { Promise } from "es6-promise";
import fileUtils from "./file-utils";
import git from "./git";
import packageUtils from "./package-utils";
Expand Down
5 changes: 3 additions & 2 deletions src/file-utils.js
@@ -1,5 +1,6 @@
import {Promise} from "es6-promise";
import { Promise } from "es6-promise";
import fs from "fs";
import { NUM_JSON_SPACES } from "./constants";
import logger from "./logger";


Expand Down Expand Up @@ -112,7 +113,7 @@ const fileUtils = {
let contents;

try {
contents = JSON.stringify(json, null, 2);
contents = JSON.stringify(json, null, NUM_JSON_SPACES);
} catch (err) {
return Promise.reject(err);
}
Expand Down
4 changes: 2 additions & 2 deletions src/git.js
@@ -1,5 +1,5 @@
import {exec} from "child_process";
import {Promise} from "es6-promise";
import { exec } from "child_process";
import { Promise } from "es6-promise";
import logger from "./logger";


Expand Down
16 changes: 8 additions & 8 deletions test/.eslintrc
@@ -1,9 +1,9 @@
---
"env":
"mocha": true
"globals":
"expect": true
"rules":
"max-nested-callbacks": 0
"max-params": 0
"no-magic-numbers": 0
env:
mocha: true
globals:
expect: true

rules:
import/no-unresolved: off
no-magic-numbers: off
2 changes: 1 addition & 1 deletion test/spec/cli.spec.js
@@ -1,7 +1,7 @@
import args from "args";
import cli from "cli";
import dryRunner from "dry-runner";
import {Promise} from "es6-promise";
import { Promise } from "es6-promise";
import logger from "logger";
import postpublish from "postpublish";
import postversion from "postversion";
Expand Down
8 changes: 4 additions & 4 deletions test/spec/dry-runner.spec.js
@@ -1,5 +1,5 @@
import dryRunner from "dry-runner";
import {Promise} from "es6-promise";
import { Promise } from "es6-promise";
import fileUtils from "file-utils";
import git from "git";
import logger from "logger";
Expand Down Expand Up @@ -39,7 +39,7 @@ describe("dryRunner", () => {
it("should set up before the dry run", () => {
sandbox.stub(dryRunner, "patchFileSystem").returns(Promise.resolve());
sandbox.stub(dryRunner, "validateFiles", (json) => {
return Promise.resolve({files: "mock files", json});
return Promise.resolve({ files: "mock files", json });
});
sandbox.stub(dryRunner, "validatePackage", (json) => Promise.resolve(json));
sandbox.stub(fileUtils, "readPackage").returns(Promise.resolve("mock json"));
Expand Down Expand Up @@ -247,15 +247,15 @@ describe("dryRunner", () => {
});

it("should validate a file write for no file", () => {
sandbox.stub(fileUtils, "statFile").returns(Promise.reject({code: "ENOENT"}));
sandbox.stub(fileUtils, "statFile").returns(Promise.reject({ code: "ENOENT" }));

return dryRunner.validateFileWrite(".npmignore.publishr").then((result) => {
expect(result).to.equal(undefined);
});
});

it("should invalidate a file write", () => {
sandbox.stub(fileUtils, "statFile").returns(Promise.reject({code: "EACCES"}));
sandbox.stub(fileUtils, "statFile").returns(Promise.reject({ code: "EACCES" }));

return dryRunner.validateFileWrite(".npmignore.publishr").catch((err) => {
expect(err).to.have.property("code", "EACCES");
Expand Down
2 changes: 1 addition & 1 deletion test/spec/end-to-end.spec.js
@@ -1,5 +1,5 @@
import childProcess from "child_process";
import {Promise} from "es6-promise";
import { Promise } from "es6-promise";
import fileUtils from "file-utils";
import mockfs from "mock-fs";
import postpublish from "postpublish";
Expand Down
4 changes: 2 additions & 2 deletions test/spec/error-handler.spec.js
Expand Up @@ -19,7 +19,7 @@ describe("errorHandler", () => {

describe("onError", () => {
it("should handle an error with a stack", () => {
const err = {stack: "mock stack"};
const err = { stack: "mock stack" };

errorHandler.onError(err);
expect(logger.error)
Expand All @@ -28,7 +28,7 @@ describe("errorHandler", () => {
});

it("should handle an error without a stack", () => {
const err = {toString: () => {}};
const err = { toString: () => {} };

sandbox.stub(err, "toString").returns("mock error");

Expand Down
2 changes: 1 addition & 1 deletion test/spec/file-handler.spec.js
@@ -1,4 +1,4 @@
import {Promise} from "es6-promise";
import { Promise } from "es6-promise";
import fileUtils from "file-utils";
import fileHandler from "file-handler";
import git from "git";
Expand Down
2 changes: 1 addition & 1 deletion test/spec/file-utils.spec.js
@@ -1,4 +1,4 @@
import {Promise} from "es6-promise";
import { Promise } from "es6-promise";
import fileUtils from "file-utils";
import mockfs from "mock-fs";
import testHelpers from "../test-helpers";
Expand Down
2 changes: 1 addition & 1 deletion test/spec/logger.spec.js
Expand Up @@ -18,7 +18,7 @@ describe("logger", () => {
it("should log an fail message with an error", () => {
sandbox.stub(logger, "log");

logger.fail("mock message", {message: "mock error message"});
logger.fail("mock message", { message: "mock error message" });
expect(logger.log)
.to.have.callCount(2).and
.to.have.been.calledWith(`${logSymbols.error} ${chalk.gray("mock message")}`).and
Expand Down
2 changes: 1 addition & 1 deletion test/spec/postpublish.spec.js
@@ -1,4 +1,4 @@
import {Promise} from "es6-promise";
import { Promise } from "es6-promise";
import fileUtils from "file-utils";
import fileHandler from "file-handler";
import postpublish from "postpublish";
Expand Down
4 changes: 2 additions & 2 deletions test/spec/postversion.spec.js
@@ -1,4 +1,4 @@
import {Promise} from "es6-promise";
import { Promise } from "es6-promise";
import fileHandler from "file-handler";
import fileUtils from "file-utils";
import postversion from "postversion";
Expand All @@ -18,7 +18,7 @@ describe("postversion", () => {
dependencies: ["^babel"]
}
};
const files = [{newPath: "file.js"}];
const files = [{ newPath: "file.js" }];

sandbox.stub(fileHandler, "overwriteFiles").returns(Promise.resolve(files));
sandbox.stub(fileUtils, "readPackage").returns(Promise.resolve(contents));
Expand Down
2 changes: 1 addition & 1 deletion test/test-helpers.js
@@ -1,4 +1,4 @@
import {Promise} from "es6-promise";
import { Promise } from "es6-promise";
import fs from "fs";


Expand Down

0 comments on commit b81c4af

Please sign in to comment.