@gkalpak/aliases 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/config/cfgbash.js +1 -1
- package/bin/config/cfgbash.wsl.js +1 -1
- package/bin/config/cfggit.js +1 -1
- package/bin/config/cfggit.wsl.js +1 -1
- package/bin/config/cfgvim.js +1 -1
- package/bin/misc/alv.js +1 -1
- package/lib/utils.js +14 -10
- package/package.json +1 -1
package/bin/config/cfgbash.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {stripIndentation} from '../../lib/utils.js';
|
|
3
3
|
/* eslint-disable max-len */
|
|
4
4
|
console.log(stripIndentation(`
|
|
5
|
-
### [Generated by: @gkalpak/aliases v0.10.
|
|
5
|
+
### [Generated by: @gkalpak/aliases v0.10.1]
|
|
6
6
|
### Copy the following into '~/.bashrc':
|
|
7
7
|
|
|
8
8
|
# Set up prompt.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {stripIndentation} from '../../lib/utils.js';
|
|
3
3
|
/* eslint-disable max-len */
|
|
4
4
|
console.log(stripIndentation(`
|
|
5
|
-
### [Generated by: @gkalpak/aliases v0.10.
|
|
5
|
+
### [Generated by: @gkalpak/aliases v0.10.1]
|
|
6
6
|
### Copy the following into '~/.bashrc':
|
|
7
7
|
|
|
8
8
|
# Set up prompt.
|
package/bin/config/cfggit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {stripIndentation} from '../../lib/utils.js';
|
|
3
3
|
console.log(stripIndentation(`
|
|
4
|
-
### [Generated by: @gkalpak/aliases v0.10.
|
|
4
|
+
### [Generated by: @gkalpak/aliases v0.10.1]
|
|
5
5
|
### Run the following commands:
|
|
6
6
|
|
|
7
7
|
git config --global commit.gpgSign true
|
package/bin/config/cfggit.wsl.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {stripIndentation} from '../../lib/utils.js';
|
|
3
3
|
console.log(stripIndentation(`
|
|
4
|
-
### [Generated by: @gkalpak/aliases v0.10.
|
|
4
|
+
### [Generated by: @gkalpak/aliases v0.10.1]
|
|
5
5
|
### Run the following commands:
|
|
6
6
|
|
|
7
7
|
git config --global commit.gpgSign true
|
package/bin/config/cfgvim.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
import {readFileSync} from 'node:fs';
|
|
3
3
|
import {fileURLToPath} from 'node:url';
|
|
4
4
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
5
|
-
console.log('""" [Generated by: @gkalpak/aliases v0.10.
|
|
5
|
+
console.log('""" [Generated by: @gkalpak/aliases v0.10.1]');
|
|
6
6
|
console.log('""" Copy the following into \'~/.vimrc\':\n');
|
|
7
7
|
console.log(readFileSync(`${__dirname}/../../lib/assets/vimrc.txt`, 'utf8').trim() + '\n');
|
package/bin/misc/alv.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
console.log('@gkalpak/aliases v0.10.
|
|
2
|
+
console.log('@gkalpak/aliases v0.10.1');
|
package/lib/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Imports
|
|
2
|
-
import {readFileSync} from 'node:fs';
|
|
2
|
+
import {existsSync, readFileSync, realpathSync} from 'node:fs';
|
|
3
3
|
import {createRequire} from 'node:module';
|
|
4
4
|
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
5
5
|
|
|
@@ -11,6 +11,8 @@ const LINE_LIMIT = 75;
|
|
|
11
11
|
const INDENT_PER_LEVEL = 2;
|
|
12
12
|
const PLATFORM = isWsl ? 'wsl' : process.platform;
|
|
13
13
|
const internal = {
|
|
14
|
+
_fsExistsSync,
|
|
15
|
+
_fsRealpathSync,
|
|
14
16
|
_getPlatform,
|
|
15
17
|
_import,
|
|
16
18
|
_onError,
|
|
@@ -35,6 +37,14 @@ export {
|
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
// Helpers
|
|
40
|
+
function _fsExistsSync(path) {
|
|
41
|
+
return existsSync(path);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function _fsRealpathSync(path) {
|
|
45
|
+
return realpathSync(path);
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
function _getPlatform() {
|
|
39
49
|
return PLATFORM;
|
|
40
50
|
}
|
|
@@ -113,17 +123,11 @@ async function importWithEnv(targetImportPath, sourceImportMetaUrl, tempEnvVars)
|
|
|
113
123
|
}
|
|
114
124
|
|
|
115
125
|
function isMain(fileUrl) {
|
|
116
|
-
const
|
|
117
|
-
|
|
126
|
+
const mainExt = ['', '.js'].find(ext => internal._fsExistsSync(`${process.argv[1]}${ext}`)) ?? '';
|
|
127
|
+
const mainPath = internal._fsRealpathSync(`${process.argv[1]}${mainExt}`);
|
|
118
128
|
const filePath = fileURLToPath(fileUrl);
|
|
119
|
-
const mainPath = process.argv[1];
|
|
120
|
-
|
|
121
|
-
const filePathExt = extRe.exec(filePath)?.[0];
|
|
122
|
-
const mainPathExt = extRe.exec(mainPath)?.[0];
|
|
123
129
|
|
|
124
|
-
return
|
|
125
|
-
((filePathExt !== null) && (filePath === `${mainPath}${filePathExt}`)) ||
|
|
126
|
-
((mainPathExt !== null) && (`${filePath}${mainPathExt}` === mainPath));
|
|
130
|
+
return filePath === mainPath;
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
function loadJson(filePath) {
|