Skip to content

Commit

Permalink
feat: init epicfail inside create function
Browse files Browse the repository at this point in the history
  • Loading branch information
uetchy committed Aug 4, 2020
1 parent d55fdca commit b7168ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"version": "5.7.0",
"author": "Yasuaki Uechi <[email protected]>",
"scripts": {
"build": "shx rm -rf lib && npm run build:ts --minify --dts",
"build": "shx rm -rf lib && yarn build:ts --minify --dts",
"build:ts": "tsup src/index.ts src/cli.ts -d lib",
"dev": "npm run build:ts --watch",
"prepublishOnly": "npm run build",
"dev": "yarn build:ts --watch",
"prepublishOnly": "yarn build",
"release": "release-it",
"test": "echo notest"
},
Expand Down
5 changes: 0 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#!/usr/bin/env node

import chalk from 'chalk';
import epicfail from 'epicfail';
import { resolve } from 'path';
import { AfterHookOptions, create } from '.';

epicfail({
assertExpected: (err) => err.name === 'CLIError',
});

const templateRoot = resolve(__dirname, '..', 'templates');
const caveat = ({ name, template }: AfterHookOptions) => {
let text = `
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import chalk from 'chalk';
import { CommonSpawnOptions } from 'child_process';
import { spawn } from 'cross-spawn';
import epicfail from 'epicfail';
import execa, { CommonOptions, ExecaChildProcess } from 'execa';
import fs from 'fs';
import gitconfig from 'gitconfig';
Expand Down Expand Up @@ -65,7 +66,7 @@ export interface AfterHookOptions {
installNpmPackage: (packageName: string) => Promise<void>;
}

class CLIError extends Error {
export class CLIError extends Error {
constructor(message: string) {
super(message);
this.name = 'CLIError';
Expand Down Expand Up @@ -196,6 +197,10 @@ async function getYargsOptions(
}

export async function create(appName: string, options: Options) {
epicfail({
assertExpected: (err) => err.name === 'CLIError',
});

const firstArg = process.argv[2];
if (firstArg === undefined) {
throw new CLIError(`${appName} <name>`);
Expand Down

0 comments on commit b7168ad

Please sign in to comment.