Skip to content

Commit

Permalink
fix: windows paths and line-endings
Browse files Browse the repository at this point in the history
  • Loading branch information
gmickel committed Jul 20, 2024
1 parent 2e47a26 commit 21743e2
Show file tree
Hide file tree
Showing 3 changed files with 2,989 additions and 12 deletions.
15 changes: 4 additions & 11 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
#!/usr/bin/env node

import path from 'node:path';
import url from 'node:url';

// Determine the directory of the current file
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

// Determine the correct path to the built CLI entry point
let cliPath;
if (__dirname.includes('/dist')) {
// In production, use the built ESM module
cliPath = path.resolve(__dirname, 'cli/index.js');
if (__dirname.includes(`${path.sep}dist`)) {
cliPath = path.resolve(__dirname, 'cli', 'index.js');
} else {
// In development, use the TypeScript source file
cliPath = path.resolve(__dirname, 'src/cli/index.ts');
cliPath = path.resolve(__dirname, 'src', 'cli', 'index.ts');
}

import(cliPath)
import(url.pathToFileURL(cliPath).href)
.then((cliModule) => {
// Check compatibly whether default or named export `cli`
if (cliModule.default) {
cliModule.default(process.argv.slice(2));
} else if (cliModule.cli) {
Expand Down
Loading

0 comments on commit 21743e2

Please sign in to comment.