Fix __dirname problem in scripts

main
Jackson Morgan 4 months ago
parent 6126ea67c4
commit d355cd639f
  1. 10
      packages/cli/src/build.ts
  2. 12
      packages/cli/src/create.ts
  3. 6
      packages/cli/src/generateReadme.ts
  4. 6
      packages/cli/src/init.ts

@ -6,17 +6,19 @@ import schemaConverterShex from "@ldo/schema-converter-shex";
import { renderFile } from "ejs";
import prettier from "prettier";
import loading from "loading-cli";
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { forAllShapes } from "./util/forAllShapes.js";
import {fileURLToPath} from 'url';
const __filename = fileURLToPath(import.meta.url);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const __dirname = dirname(fileURLToPath(import.meta.url));
interface BuildOptions {
input: string;
output: string;
}
const __dirname = path.dirname(__filename);
export async function build(options: BuildOptions) {
const load = loading("Preparing Environment");
load.start();

@ -1,12 +1,20 @@
import { init } from "./init.js";
import { modifyPackageJson, savePackageJson } from "./util/modifyPackageJson.js";
import {
modifyPackageJson,
savePackageJson,
} from "./util/modifyPackageJson.js";
import { generateReadme } from "./generateReadme.js";
import path from "path";
import prompts from "prompts";
import type { PackageJson } from "type-fest";
import loading from "loading-cli";
import { promises as fs } from "fs";
import { renderFile } from "ejs";
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const __dirname = dirname(fileURLToPath(import.meta.url));
export async function create(directory: string) {
// Init the NPM Package

@ -4,6 +4,12 @@ import { promises as fs } from "fs";
import path from "path";
import { Project } from "ts-morph";
import { renderFile } from "ejs";
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const __dirname = dirname(fileURLToPath(import.meta.url));
interface GenerateReadmeOptions {
project: string;

@ -3,6 +3,12 @@ import fs from "fs-extra";
import path from "path";
import { renderFile } from "ejs";
import { modifyPackageJson } from "./util/modifyPackageJson.js";
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const __dirname = dirname(fileURLToPath(import.meta.url));
const DEFAULT_SHAPES_FOLDER = "./.shapes";
const DEFAULT_LDO_FOLDER = "./.ldo";

Loading…
Cancel
Save