Skip to content

Commit

Permalink
Moving some things around.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterp committed Jun 30, 2019
1 parent cd64e67 commit 91dc504
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 16 deletions.
10 changes: 0 additions & 10 deletions packages/hammer-cli/src/__tests__/__snapshots__/index.test.js.snap

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const Generate = ({

const generator = generators[generatorName];

// If no generator is specified list the
if (!generator || !name) {
return (
<>
Expand Down Expand Up @@ -78,6 +77,7 @@ const Generate = ({
};

export const commandProps = {
name: 'generate',
alias: 'g',
description: 'save time by generating boilerplate code',
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render } from 'ink-testing-library';

import Generate from './generate';
import Generate from './Generate';

describe('Command: Generate', () => {
const generators = {
Expand Down
2 changes: 1 addition & 1 deletion packages/hammer-cli/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import React from 'react';
import { render, Color, Text, Box } from 'ink';
import { render, Box } from 'ink';

import { getCommands, parseArgs } from 'src/lib';
import { Header, CommandList } from 'src/components';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render } from 'ink-testing-library';

import Router from '../index';
import Router from './';

describe('Router', () => {
const commands = [
Expand Down Expand Up @@ -29,7 +29,7 @@ describe('Router', () => {

it('the default menu is shown when no arguments are passed', () => {
const { lastFrame } = renderComponent();
expect(lastFrame()).toMatchSnapshot();
expect(lastFrame()).toMatch(/Commands/g);
});

it('routes to the correct command when the name is matched ', () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/hammer-cli/src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ export const getCommands = (commandsPath = '../commands') => {
const foundCommands = requireDir(commandsPath, {
recurse: true,
extensions: ['.js'],
filter: fullPath => {
return fullPath.indexOf('.test.js') === -1;
},
});

return Object.keys(foundCommands).reduce((newCommands, commandName) => {
let command = foundCommands[commandName];
// is this a directory-named-modules? Eg: `/generate/generate.js`
// is this a directory-named-modules? Eg: `/Generate/Generate.js`
// NOTE: Improve this by looking at the file names before importing
// everything.
if (command.index && command.index.default) {
Expand Down

0 comments on commit 91dc504

Please sign in to comment.