@jdeighan/coffee-utils 16.0.4 → 16.0.5
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/package.json +3 -3
- package/src/fs.coffee +5 -49
- package/src/fs.js +14 -54
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jdeighan/coffee-utils",
|
3
3
|
"type": "module",
|
4
|
-
"version": "16.0.
|
4
|
+
"version": "16.0.5",
|
5
5
|
"description": "A set of utility functions for CoffeeScript",
|
6
6
|
"main": "coffee_utils.js",
|
7
7
|
"exports": {
|
@@ -45,14 +45,14 @@
|
|
45
45
|
},
|
46
46
|
"homepage": "https://github.com/johndeighan/coffee-utils#readme",
|
47
47
|
"dependencies": {
|
48
|
-
"@jdeighan/base-utils": "^4.0.
|
48
|
+
"@jdeighan/base-utils": "^4.0.33",
|
49
49
|
"cross-env": "^7.0.3",
|
50
50
|
"n-readlines": "^1.0.1",
|
51
51
|
"readline-sync": "^1.4.10",
|
52
52
|
"svelte": "^3.59.1"
|
53
53
|
},
|
54
54
|
"devDependencies": {
|
55
|
-
"@jdeighan/unit-tester": "^3.0.
|
55
|
+
"@jdeighan/unit-tester": "^3.0.47",
|
56
56
|
"ava": "^5.3.0"
|
57
57
|
}
|
58
58
|
}
|
package/src/fs.coffee
CHANGED
@@ -16,11 +16,16 @@ import {
|
|
16
16
|
isString, isArray, isHash, isRegExp, isFunction, isBoolean,
|
17
17
|
OL, toBlock, getOptions, isArrayOfStrings,
|
18
18
|
} from '@jdeighan/base-utils'
|
19
|
+
import {
|
20
|
+
mkpath, isFile, isDir, mkdirSync,
|
21
|
+
} from '@jdeighan/base-utils/fs'
|
19
22
|
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
20
23
|
import {LOG, LOGVALUE} from '@jdeighan/base-utils/log'
|
21
24
|
import {dbg, dbgEnter, dbgReturn} from '@jdeighan/base-utils/debug'
|
22
25
|
import {fromTAML} from '@jdeighan/base-utils/taml'
|
23
26
|
|
27
|
+
export {mkpath, isFile, isDir, mkdirSync}
|
28
|
+
|
24
29
|
fix = true
|
25
30
|
|
26
31
|
# ---------------------------------------------------------------------------
|
@@ -32,37 +37,6 @@ export doFixOutput = (flag=true) =>
|
|
32
37
|
|
33
38
|
# ---------------------------------------------------------------------------
|
34
39
|
|
35
|
-
export mkpath = (lParts...) =>
|
36
|
-
|
37
|
-
# --- Ignore empty parts
|
38
|
-
lNewParts = []
|
39
|
-
for part in lParts
|
40
|
-
if nonEmpty(part)
|
41
|
-
lNewParts.push part
|
42
|
-
|
43
|
-
newPath = lNewParts.join('/').replaceAll('\\', '/')
|
44
|
-
if lMatches = newPath.match(/^([A-Z])\:(.*)$/)
|
45
|
-
[_, drive, rest] = lMatches
|
46
|
-
return "#{drive.toLowerCase()}:#{rest}"
|
47
|
-
else
|
48
|
-
return newPath
|
49
|
-
|
50
|
-
# ---------------------------------------------------------------------------
|
51
|
-
|
52
|
-
export mkdirSync = (dirpath) =>
|
53
|
-
|
54
|
-
try
|
55
|
-
fs.mkdirSync dirpath
|
56
|
-
catch err
|
57
|
-
if (err.code == 'EEXIST')
|
58
|
-
console.log 'Directory exists. Please choose another name'
|
59
|
-
else
|
60
|
-
console.log err
|
61
|
-
process.exit 1
|
62
|
-
return
|
63
|
-
|
64
|
-
# ---------------------------------------------------------------------------
|
65
|
-
|
66
40
|
export rmDir = (dirpath) =>
|
67
41
|
|
68
42
|
await rmdir dirpath, {recursive: true}
|
@@ -212,24 +186,6 @@ export getStats = (fullpath) =>
|
|
212
186
|
|
213
187
|
# ---------------------------------------------------------------------------
|
214
188
|
|
215
|
-
export isFile = (fullpath) =>
|
216
|
-
|
217
|
-
try
|
218
|
-
return getStats(fullpath).isFile()
|
219
|
-
catch
|
220
|
-
return false
|
221
|
-
|
222
|
-
# ---------------------------------------------------------------------------
|
223
|
-
|
224
|
-
export isDir = (fullpath) =>
|
225
|
-
|
226
|
-
try
|
227
|
-
return getStats(fullpath).isDirectory()
|
228
|
-
catch
|
229
|
-
return false
|
230
|
-
|
231
|
-
# ---------------------------------------------------------------------------
|
232
|
-
|
233
189
|
export isSimpleFileName = (path) =>
|
234
190
|
|
235
191
|
h = pathlib.parse(path)
|
package/src/fs.js
CHANGED
@@ -45,6 +45,13 @@ import {
|
|
45
45
|
isArrayOfStrings
|
46
46
|
} from '@jdeighan/base-utils';
|
47
47
|
|
48
|
+
import {
|
49
|
+
mkpath,
|
50
|
+
isFile,
|
51
|
+
isDir,
|
52
|
+
mkdirSync
|
53
|
+
} from '@jdeighan/base-utils/fs';
|
54
|
+
|
48
55
|
import {
|
49
56
|
assert,
|
50
57
|
croak
|
@@ -65,6 +72,13 @@ import {
|
|
65
72
|
fromTAML
|
66
73
|
} from '@jdeighan/base-utils/taml';
|
67
74
|
|
75
|
+
export {
|
76
|
+
mkpath,
|
77
|
+
isFile,
|
78
|
+
isDir,
|
79
|
+
mkdirSync
|
80
|
+
};
|
81
|
+
|
68
82
|
fix = true;
|
69
83
|
|
70
84
|
// ---------------------------------------------------------------------------
|
@@ -72,42 +86,6 @@ export var doFixOutput = (flag = true) => {
|
|
72
86
|
fix = flag;
|
73
87
|
};
|
74
88
|
|
75
|
-
// ---------------------------------------------------------------------------
|
76
|
-
export var mkpath = (...lParts) => {
|
77
|
-
var _, drive, i, lMatches, lNewParts, len, newPath, part, rest;
|
78
|
-
// --- Ignore empty parts
|
79
|
-
lNewParts = [];
|
80
|
-
for (i = 0, len = lParts.length; i < len; i++) {
|
81
|
-
part = lParts[i];
|
82
|
-
if (nonEmpty(part)) {
|
83
|
-
lNewParts.push(part);
|
84
|
-
}
|
85
|
-
}
|
86
|
-
newPath = lNewParts.join('/').replaceAll('\\', '/');
|
87
|
-
if (lMatches = newPath.match(/^([A-Z])\:(.*)$/)) {
|
88
|
-
[_, drive, rest] = lMatches;
|
89
|
-
return `${drive.toLowerCase()}:${rest}`;
|
90
|
-
} else {
|
91
|
-
return newPath;
|
92
|
-
}
|
93
|
-
};
|
94
|
-
|
95
|
-
// ---------------------------------------------------------------------------
|
96
|
-
export var mkdirSync = (dirpath) => {
|
97
|
-
var err;
|
98
|
-
try {
|
99
|
-
fs.mkdirSync(dirpath);
|
100
|
-
} catch (error1) {
|
101
|
-
err = error1;
|
102
|
-
if (err.code === 'EEXIST') {
|
103
|
-
console.log('Directory exists. Please choose another name');
|
104
|
-
} else {
|
105
|
-
console.log(err);
|
106
|
-
}
|
107
|
-
process.exit(1);
|
108
|
-
}
|
109
|
-
};
|
110
|
-
|
111
89
|
// ---------------------------------------------------------------------------
|
112
90
|
export var rmDir = async(dirpath) => {
|
113
91
|
await rmdir(dirpath, {
|
@@ -264,24 +242,6 @@ export var getStats = (fullpath) => {
|
|
264
242
|
return fs.lstatSync(fullpath);
|
265
243
|
};
|
266
244
|
|
267
|
-
// ---------------------------------------------------------------------------
|
268
|
-
export var isFile = (fullpath) => {
|
269
|
-
try {
|
270
|
-
return getStats(fullpath).isFile();
|
271
|
-
} catch (error1) {
|
272
|
-
return false;
|
273
|
-
}
|
274
|
-
};
|
275
|
-
|
276
|
-
// ---------------------------------------------------------------------------
|
277
|
-
export var isDir = (fullpath) => {
|
278
|
-
try {
|
279
|
-
return getStats(fullpath).isDirectory();
|
280
|
-
} catch (error1) {
|
281
|
-
return false;
|
282
|
-
}
|
283
|
-
};
|
284
|
-
|
285
245
|
// ---------------------------------------------------------------------------
|
286
246
|
export var isSimpleFileName = (path) => {
|
287
247
|
var h;
|