Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make lint-script command; lint now runs scripts and style #339

Merged
merged 1 commit into from
Dec 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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);