Skip to content

Commit 70ce3f4

Browse files
committed
fix create ts
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent 12fb052 commit 70ce3f4

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

Diff for: src/cli.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import arg from "arg";
21
import * as inquirer from "inquirer";
32
import simpleGit from "simple-git/promise";
43
import * as fs from "fs";
54
import * as T from "../typings/tutorial";
65
import build, { BuildOptions } from "./build";
76
import create from "./create";
87

8+
// import not working
9+
const arg = require("arg");
10+
911
type Q = inquirer.Question<any> & { choices?: string[] };
1012

1113
type ParsedArgs = {
@@ -49,18 +51,21 @@ function parseArgumentsIntoOptions(rawArgs: string[]): ParsedArgs {
4951
argv: rawArgs.slice(2),
5052
}
5153
);
54+
console.log(args);
5255
return {
5356
command: args["_"][0],
5457
git: args["--git"],
5558
dir: args["--dir"],
5659
codeBranch: args["--code"],
5760
setupBranch: args["--setup"],
58-
output: args["--output"],
61+
output: args["--output"] || "./config.json",
5962
help: args["--help"] || false,
6063
};
6164
}
6265

63-
async function promptForMissingOptions(options: ParsedArgs): Promise<Options> {
66+
export async function promptForMissingOptions(
67+
options: ParsedArgs
68+
): Promise<Options> {
6469
const questions: Q[] = [];
6570

6671
// if no git remote addres is provided, assume current folder
@@ -147,7 +152,7 @@ async function promptForMissingOptions(options: ParsedArgs): Promise<Options> {
147152
};
148153
}
149154

150-
export async function cli(args: string[]) {
155+
export async function cli(args: string[]): Promise<void> {
151156
let parsedArgs: ParsedArgs = parseArgumentsIntoOptions(args);
152157

153158
// If help called just print the help text and exit
@@ -174,11 +179,12 @@ export async function cli(args: string[]) {
174179
console.log(JSON.stringify(tutorial, null, 2));
175180
}
176181
}
177-
return;
182+
break;
178183

179184
case "create":
185+
console.log("here");
180186
create(process.cwd());
181-
return;
187+
break;
182188
}
183189
}
184190
}

Diff for: src/create.ts

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
import * as ncp from "ncp";
22
import * as path from "path";
33
import { promisify } from "util";
4-
import * as os from "os";
54

65
const copy = promisify(ncp);
76

8-
const copyFiles = async (filePath: string) => {
7+
const copyFiles = async (filePath: string): Promise<void> => {
98
try {
10-
let filePath = new URL(import.meta.url).pathname;
11-
12-
if (os.platform() === "win32") {
13-
// removes the leading drive letter from the path
14-
filePath = filePath.substr(3);
15-
}
16-
17-
const templateDirectory = path.resolve(filePath, "..", "templates");
18-
9+
const pathToSrc = path.join(__dirname, "..", "src");
10+
const templateDirectory = path.resolve(pathToSrc, "templates");
1911
const targetDirectory = process.cwd();
2012

2113
await copy(templateDirectory, targetDirectory, {

Diff for: tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"module": "esnext",
3+
"module": "commonjs",
44
"target": "es2018",
55
"outDir": "build",
66
"lib": ["es2018", "dom"],
@@ -22,5 +22,5 @@
2222
"removeComments": true,
2323
"skipLibCheck": true
2424
},
25-
"exclude": ["node_modules", ".vscode", "bin", "build", "test"]
25+
"exclude": [".vscode", "bin", "build", "test"]
2626
}

0 commit comments

Comments
 (0)