Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Dec 29, 2019
1 parent e7566c0 commit f01dabe
Show file tree
Hide file tree
Showing 12 changed files with 242 additions and 219 deletions.
6 changes: 5 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ license_task:
install_script: npm ci
test_script: npm run license-check

system_test_task:
install_script: npm ci
test_script: npm run system-test

test_task:
container:
matrix:
image: node:13
image: node:12
image: node:11
image: node:10
image: node:8
install_script: npm ci
Expand Down
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/camelcase": "off",
"node/no-missing-require": "off",
"no-dupe-class-members": "off"
"no-dupe-class-members": "off",
"node/shebang": "off"
},
"parserOptions": {
"ecmaVersion": 2018,
Expand Down
400 changes: 208 additions & 192 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
},
"files": [
"CHANGELOG.md",
"LICENSE",
"README.md",
"build/src",
"build/types",
"build/template",
"prettier.config.js",
"tsconfig-google.json",
Expand All @@ -27,8 +24,10 @@
"postcompile": "ncp template build/template",
"lint": "eslint '**/*.ts'",
"prepare": "npm run compile",
"test": "c8 mocha build/test",
"test": "c8 mocha build/test/test-*.js",
"system-test": "c8 mocha build/test/kitchen.js",
"pretest": "npm run compile",
"presystem-test": "npm run compile",
"license-check": "jsgl --local .",
"fix": "eslint --fix '**/*.ts'"
},
Expand All @@ -42,7 +41,6 @@
"@typescript-eslint/eslint-plugin": "^2.9.0",
"@typescript-eslint/parser": "^2.9.0",
"chalk": "^3.0.0",
"diff": "^4.0.1",
"eslint": "^6.7.1",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-node": "^10.0.0",
Expand All @@ -59,7 +57,6 @@
"devDependencies": {
"@npm/types": "^1.0.1",
"@types/cross-spawn": "^6.0.0",
"@types/diff": "^4.0.0",
"@types/eslint": "^6.1.3",
"@types/fs-extra": "^8.0.0",
"@types/inquirer": "^6.0.0",
Expand Down
20 changes: 14 additions & 6 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,30 +109,38 @@ async function run(verb: string, files: string[]): Promise<boolean> {
return init(options);
}

const flags = Object.assign({}, files);
const flags = Object.assign([], files);
if (flags.length === 0) {
flags.push('**/*.ts', '**/*.js');
}

switch (verb) {
case 'check': {
try {
await execa('npx', ['eslint', ...flags], { stdio: 'inherit' });
await execa('node', ['./node_modules/eslint/bin/eslint', ...flags], {
stdio: 'inherit',
});
return true;
} catch (e) {
return false;
}
}
case 'fix':
case 'fix': {
const fixFlag = options.dryRun ? '--fix-dry-run' : '--fix';
try {
await execa('npx', ['eslint', fixFlag, ...flags], {
stdio: 'inherit',
});
await execa(
'node',
['./node_modules/eslint/bin/eslint', fixFlag, ...flags],
{
stdio: 'inherit',
}
);
return true;
} catch (e) {
console.error(e);
return false;
}
}
case 'clean':
return clean(options);
default:
Expand Down
5 changes: 0 additions & 5 deletions test/.eslintrc.json

This file was deleted.

4 changes: 1 addition & 3 deletions test/test-kitchen.ts → test/kitchen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as fs from 'fs-extra';
import * as tmp from 'tmp';
import * as assert from 'assert';
import * as path from 'path';
import { describe, it, before, after } from 'mocha';

import spawn = require('cross-spawn');
// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand All @@ -25,16 +26,13 @@ describe('🚰 kitchen sink', () => {

// Create a staging directory with temp fixtures used to test on a fresh application.
before(() => {
console.log('running before hook.');
cp.execSync('npm pack');
const tarball = `${pkg.name}-${pkg.version}.tgz`;
fs.renameSync(tarball, 'gts.tgz');
const targetPath = path.resolve(stagingPath, 'gts.tgz');
console.log('moving packed tar to ', targetPath);
fs.moveSync('gts.tgz', targetPath);
fs.copySync(fixturesPath, path.join(stagingPath, path.sep));
console.log(fs.readdirSync(stagingPath));
console.log(fs.readdirSync(path.join(stagingPath, 'kitchen')));
});
// CLEAN UP - remove the staging directory when done.
after('cleanup staging', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/test-clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import * as fs from 'fs';
import * as path from 'path';

import { clean } from '../src/clean';
import { Options } from '../src/cli';
import { nop } from '../src/util';

import { withFixtures } from 'inline-fixtures';
import { describe, it } from 'mocha';

describe('clean', () => {
const OPTIONS: Options = {
const OPTIONS = {
gtsRootDir: path.resolve(__dirname, '../..'),
targetRootDir: './',
dryRun: false,
Expand Down
1 change: 1 addition & 0 deletions test/test-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { nop } from '../src/util';
const format: any = {};

import { withFixtures } from 'inline-fixtures';
import { describe, it } from 'mocha';

describe('format', () => {
const BAD_CODE = 'export const foo = [ "2" ];';
Expand Down
6 changes: 4 additions & 2 deletions test/test-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import * as assert from 'assert';
import * as fs from 'fs';
import * as path from 'path';
import { accessSync } from 'fs';
import { nop, readJsonp as readJson, DefaultPackage } from '../src/util';
import { Options } from '../src/cli';
import { PackageJson } from '@npm/types';
import { withFixtures, Fixtures } from 'inline-fixtures';
import { describe, it, beforeEach, afterEach } from 'mocha';

import { nop, readJsonp as readJson, DefaultPackage } from '../src/util';
import { Options } from '../src/cli';
import * as init from '../src/init';

const OPTIONS: Options = {
Expand Down
1 change: 1 addition & 0 deletions test/test-lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { TSLINT_CONFIG } from '../src/init';
import { nop } from '../src/util';

import { withFixtures } from 'inline-fixtures';
import { describe, it } from 'mocha';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const format: any = {};
Expand Down
2 changes: 1 addition & 1 deletion test/test-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import * as assert from 'assert';
import * as path from 'path';
import { PathLike } from 'fs';

import { describe, it } from 'mocha';
import {
ConfigFile,
getTSConfig,
Expand Down

0 comments on commit f01dabe

Please sign in to comment.