Skip to content

Commit b97bfa8

Browse files
committed
code: add is_pkg flag
1 parent 087c2bb commit b97bfa8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/env.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@
1919

2020
"use strict";
2121

22+
const path = require('path');
23+
2224
global.UTIL = require('./util');
25+
global.IS_PKG = !path.basename(process.execPath).startsWith('node');

src/util.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ function _remove_undefined(arr) {
3131
}
3232

3333
/* Return plugin directory */
34-
function plugin_dir() { return path.join(__dirname, '..'); }
34+
function plugin_dir() {
35+
let root = (IS_PKG) ? process.execPath : __dirname;
36+
return path.join(root, '..');
37+
}
3538

3639
/**
3740
* Define flag with proper alias flag.

0 commit comments

Comments
 (0)