Skip to content

Commit

Permalink
Use cwd over __dirname and fix package imports
Browse files Browse the repository at this point in the history
  • Loading branch information
nettybun committed Jun 1, 2021
1 parent a20c14c commit fdae36a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
23 changes: 21 additions & 2 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
"url": "https://github.com/heyheyhello/acorn-macros"
},
"scripts": {
"install": "cd node_modules && ln -s ../packages/acorn-macros && ln -s ../packages/style.acorn",
"build": "find packages/*.acorn/src.ts -exec bash -c 'esbuild ${0} > ${0/.ts/.js} && echo ${0}' {} \\;",
"style.acorn": "cd ./test/style.acorn/ && esbuild esbuild.ts > _.js && node _.js; rm _.js"
"test": "bash -c 'cd ./test/${1:-all} && esbuild esbuild.ts | node --input-type=module'"
},
"devDependencies": {
"@types/node": "^15.0.1",
Expand All @@ -23,5 +22,9 @@
"esbuild": "^0.11.15",
"eslint": "^7.25.0",
"typescript": "^4.2.4"
},
"dependencies": {
"acorn-macros": "file:packages/acorn-macros",
"style.acorn": "file:packages/style.acorn"
}
}
7 changes: 4 additions & 3 deletions test/style.acorn/esbuild.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import esbuild from 'esbuild';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

import { replaceMacros } from 'acorn-macros';
import {
Expand All @@ -11,8 +10,10 @@ import {
injectGlobalImpl as injectGlobal
} from 'style.acorn/src';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rel = (...paths: string[]) => path.resolve(__dirname, ...paths);
// const [, argv1] = process.argv;
// if (!argv1) throw new Error('Specify a project root folder');
// const root = path.resolve(process.cwd(), argv1);
const rel = (...paths: string[]) => path.join(process.cwd(), ...paths);

// Toss some global styles in immediately before the JS is even bundled/read.
injectGlobal`
Expand Down

0 comments on commit fdae36a

Please sign in to comment.