Skip to content

Commit

Permalink
'bump'
Browse files Browse the repository at this point in the history
  • Loading branch information
tenbits committed Jan 17, 2025
1 parent e624a7d commit c261503
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dequanto",
"version": "0.1.30",
"version": "0.1.31",
"author": {
"name": "Alex Kit",
"email": "alex.kit@atmajs.com"
Expand Down
13 changes: 13 additions & 0 deletions src/utils/$dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,18 @@ export namespace $dependency {
//#endif
}

export function dirname () {
if (typeof __dirname === 'undefined') {
return __dirname;
}
//#if (CJS)
throw new Error('__dirname is not defined in CommonJS environment');
//#endif

//#if (ESM)
// @ts-ignore: Conditional import
return import.meta.dirname;
//#endif
}
}

6 changes: 4 additions & 2 deletions src/utils/$path.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { class_Uri } from 'atma-utils';
import { $config } from './$config';
import { env } from 'atma-io';
import { $dependency } from './$dependency';

export namespace $path {
let root: string = null;
Expand Down Expand Up @@ -80,11 +81,12 @@ export namespace $path {
return class_Uri.combine('file://' + cwd, base);
}

let uri = new class_Uri('file://' + __dirname + '/');
let dirname = $dependency.dirname();
let uri = new class_Uri('file://' + dirname + '/');
while (true) {
let dir = getDirName(uri.path);
if (!dir || dir === '/') {
throw new Error(`Root path not resolved: ${__dirname}`);
throw new Error(`Root path not resolved: ${dirname}`);
}
if (dir === 'lib' || dir === 'src') {
uri = uri.cdUp();
Expand Down

0 comments on commit c261503

Please sign in to comment.