Skip to content

Commit

Permalink
release: v1.0.3
Browse files Browse the repository at this point in the history
- fix: 파일 경로 process.argv에서 import.meta.url을 사용하도록 변경
  • Loading branch information
HBSPS committed Jun 26, 2024
1 parent 50f4b65 commit 5f66264
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { unlink } from 'fs/promises';
import { cliConfig } from '../plugin/cliConfig';
import { getConfigFile } from '../plugin/getConfigFile';
import { FileTree } from '../plugin/FileTree';
import { generateTemplate } from '../plugin/generateTemplate';
import { __dirname, generateTemplate } from '../plugin/generateTemplate';

const { root, targetDir } = cliConfig(process.argv.slice(2));

Expand All @@ -17,7 +17,7 @@ const { baseUrl, paths } = compilerOptions;
const fileTree = new FileTree(root, targetDir, baseUrl, paths);
generateTemplate(fileTree.tree);

const resultFilePath = resolve(process.argv[1], '../../index.html');
const resultFilePath = resolve(__dirname, '../index.html');
await open(resultFilePath, { wait: true });

console.log('Tree has been created. Check your browser.');
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "import-visualizer",
"version": "1.0.0",
"version": "1.0.3",
"main": "./dist/bin/cli.js",
"type": "module",
"bin": "./dist/bin/cli.js",
Expand Down
9 changes: 6 additions & 3 deletions plugin/generateTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { readFileSync, writeFileSync } from 'fs';
import { resolve } from 'path';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';

export const __dirname = dirname(fileURLToPath(import.meta.url))

const template = (data: string) => {
const script = readFileSync(resolve(process.argv[1], '../../lib/tree.js'));
const script = readFileSync(resolve(__dirname, '../lib/tree.js'));

return `<!DOCTYPE html>
<html lang="ko">
Expand All @@ -21,5 +24,5 @@ const template = (data: string) => {
};

export function generateTemplate(data: any) {
writeFileSync(resolve(process.argv[1], '../../index.html'), template(JSON.stringify(data)));
writeFileSync(resolve(__dirname, '../index.html'), template(JSON.stringify(data)));
}

0 comments on commit 5f66264

Please sign in to comment.