Skip to content

Commit

Permalink
fix: fix some lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
painfulexistence committed Apr 26, 2024
1 parent c062e67 commit 67ec334
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 167 deletions.
28 changes: 14 additions & 14 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
#!/usr/bin/env node

import chalk from 'chalk';
import { resolve } from 'path';
import { AfterHookOptions, create } from '.';
import chalk from "chalk";
import { resolve } from "node:path";
import { type AfterHookOptions, create } from ".";

const templateRoot = resolve(__dirname, '..', 'templates');
const templateRoot = resolve(__dirname, "..", "templates");

const caveat = ({ answers: { name, template } }: AfterHookOptions) => {
let text = `
cd ${chalk.bold.green(name)}
`;

switch (template) {
case 'typescript':
case "typescript":
text += `
Inside the directory, you can run several commands:
${chalk.bold.cyan('npm run dev')}
${chalk.bold.cyan("npm run dev")}
${chalk.gray("Starts 'tsc -w'.")}
${chalk.bold.cyan('npm run build')}
${chalk.gray('Build the app for production.')}
${chalk.bold.cyan("npm run build")}
${chalk.gray("Build the app for production.")}
After the build, run ${chalk.cyan('node dist/cli.js <name>')} to test your app.
After the build, run ${chalk.cyan("node dist/cli.js <name>")} to test your app.
`;
break;
default:
Expand All @@ -32,22 +32,22 @@ After the build, run ${chalk.cyan('node dist/cli.js <name>')} to test your app.
text += `
Read the docs for the further information:
${chalk.yellow(
'https://github.com/painfulexistence/create-create-x/blob/main/README.md'
"https://github.com/painfulexistence/create-create-x/blob/main/README.md"
)}`;

return text;
};

create('create-create-x', {
create("create-create-x", {
templateRoot,
promptForTemplate: true,
skipNpmInstall: true,

modifyName: (name) => (name.startsWith('create-') ? name : `create-${name}`),
modifyName: (name) => (name.startsWith("create-") ? name : `create-${name}`),

after: async ({ installNpmPackage }: AfterHookOptions) => {
console.log('\nInstalling the latest version of create-create-x');
await installNpmPackage('create-create-x');
console.log("\nInstalling the latest version of create-create-x");
await installNpmPackage("create-create-x");
},

caveat,
Expand Down
16 changes: 8 additions & 8 deletions src/fs.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { CommonSpawnOptions } from 'child_process';
import { spawn } from 'cross-spawn';
import fs from 'fs';
import path from 'path';
import type { CommonSpawnOptions } from "node:child_process";
import { spawn } from "cross-spawn";
import fs from "node:fs";
import path from "node:path";

export function spawnPromise(
command: string,
args: string[] = [],
options: CommonSpawnOptions = {}
): Promise<number> {
return new Promise((resolve, reject) => {
const child = spawn(command, args, { stdio: 'inherit', ...options });
child.on('close', (code) => {
const child = spawn(command, args, { stdio: "inherit", ...options });
child.on("close", (code) => {
if (code !== 0) {
return reject(code);
}
Expand All @@ -26,10 +26,10 @@ export function exists(filePath: string, baseDir: string): boolean {
export function isOccupied(dirname: string) {
try {
return (
fs.readdirSync(dirname).filter((s) => !s.startsWith('.')).length !== 0
fs.readdirSync(dirname).filter((s) => !s.startsWith(".")).length !== 0
);
} catch (err: any) {
if (err?.code === 'ENOENT') {
if (err?.code === "ENOENT") {
return false;
}
throw err;
Expand Down
12 changes: 6 additions & 6 deletions src/git.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import execa from 'execa';
import gitconfig from 'gitconfig';
import { printCommand } from '.';
import execa from "execa";
import gitconfig from "gitconfig";
import { printCommand } from ".";

export async function initGit(root: string) {
printCommand('git init');
await execa('git init', { shell: true, cwd: root });
printCommand("git init");
await execa("git init", { shell: true, cwd: root });
}

export async function getGitUser(): Promise<{ name?: string; email?: string }> {
try {
const config = await gitconfig.get({ location: 'global' });
const config = await gitconfig.get({ location: "global" });
return config.user ?? {};
} catch (err) {
return {};
Expand Down
Loading

0 comments on commit 67ec334

Please sign in to comment.