Skip to content

Commit

Permalink
make lint-script command; lint now runs scripts and style (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccpricenytimes authored and delambo committed Dec 11, 2016
1 parent 0afb996 commit 384f9a8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
5 changes: 3 additions & 2 deletions e2e_tests/tests/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ describe('KYT CLI', () => {
expect(scripts.start).toBe('node build/server/main.js');
expect(scripts.build).toBe('kyt build');
expect(scripts.test).toBe('kyt test');
expect(scripts.lint).toBe('kyt lint');
expect(scripts.lint).toBe('npm run lint-script && npm run lint-style');
expect(scripts['lint-style']).toBe('kyt lint-style');
expect(scripts['lint-script']).toBe('kyt lint-script');
expect(scripts.proto).toBe('kyt proto');
expect(scripts['kyt:help']).toBe('kyt --help');
});

it('runs the lint command', () => {
expect(true).toBe(true);
const output = shell.exec('npm run lint');
const output = shell.exec('npm run lint-script');
expect(output.code).toBe(0);
const outputArr = output.stdout.split('\n');
expect(outputArr.includes('✅ Your JS looks great ✨')).toBe(true);
Expand Down
5 changes: 3 additions & 2 deletions packages/kyt-cli/cli/actions/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,17 @@ module.exports = (flags, args) => {
const addPackageJsonScripts = (packageJson) => {
if (!packageJson.scripts) packageJson.scripts = {};
let commands = [
'dev', 'build', 'start',
'dev', 'build', 'start', 'proto',
'test', 'test-watch', 'test-coverage',
'lint', 'lint-style', 'proto',
'lint', 'lint-script', 'lint-style',
];

// for commands that aren't 1:1 name:script
const commandMap = {
start: 'node build/server/main.js',
'test-watch': 'kyt test -- --watch',
'test-coverage': 'kyt test -- --coverage',
lint: 'npm run lint-script && npm run lint-style',
};

// Merge the Starter-kyt script names into the list of commands.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jest.mock('shelljs', () => (
describe('lint', () => {
global.process.exit = jest.fn();
const logger = require('kyt-utils/logger');
const lint = require('../lint');
const lint = require('../lintScript');

beforeEach(() => {
jest.resetModules();
Expand Down
File renamed without changes.
13 changes: 10 additions & 3 deletions packages/kyt-core/cli/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const program = require('commander');
const shell = require('shelljs');
const devAction = require('./actions/dev');
const lintAction = require('./actions/lint');
const lintScriptAction = require('./actions/lintScript');
const testAction = require('./actions/test');
const buildAction = require('./actions/build');
const protoAction = require('./actions/proto');
Expand Down Expand Up @@ -32,9 +32,9 @@ const loadConfigAndDo = (action, optionalConfig) => {
};

program
.command('lint')
.command('lint-script')
.description('lints .js files in the ./src directory.')
.action(() => loadConfigAndDo(lintAction));
.action(() => loadConfigAndDo(lintScriptAction));

program
.command('dev')
Expand Down Expand Up @@ -85,4 +85,11 @@ program
logger.error('kyt start is deprecated. \n Run the server with: node build/server/main.js');
});

program
.command('lint')
.description('deprecated')
.action(() => {
logger.error('kyt lint is deprecated. \n Run lint-script to lint js files.');
});

program.parse(process.argv);

0 comments on commit 384f9a8

Please sign in to comment.