@jdeighan/coffee-utils 16.0.0 → 16.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +4 -4
- package/src/fs.coffee +7 -8
- package/src/fs.js +8 -10
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.2",
|
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.27",
|
49
49
|
"cross-env": "^7.0.3",
|
50
50
|
"n-readlines": "^1.0.1",
|
51
51
|
"readline-sync": "^1.4.10",
|
52
|
-
"svelte": "^3.
|
52
|
+
"svelte": "^3.59.1"
|
53
53
|
},
|
54
54
|
"devDependencies": {
|
55
|
-
"@jdeighan/unit-tester": "^3.0.
|
55
|
+
"@jdeighan/unit-tester": "^3.0.45",
|
56
56
|
"ava": "^5.2.0"
|
57
57
|
}
|
58
58
|
}
|
package/src/fs.coffee
CHANGED
@@ -14,7 +14,7 @@ import NReadLines from 'n-readlines'
|
|
14
14
|
import {
|
15
15
|
undef, pass, defined, notdefined, rtrim, isEmpty, nonEmpty,
|
16
16
|
isString, isArray, isHash, isRegExp, isFunction, isBoolean,
|
17
|
-
OL, toBlock, getOptions,
|
17
|
+
OL, toBlock, getOptions, isArrayOfStrings,
|
18
18
|
} from '@jdeighan/base-utils'
|
19
19
|
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
20
20
|
import {LOG, LOGVALUE} from '@jdeighan/base-utils/log'
|
@@ -93,7 +93,7 @@ export rmFileSync = (filepath) =>
|
|
93
93
|
|
94
94
|
export fixOutput = (contents) =>
|
95
95
|
|
96
|
-
if fix
|
96
|
+
if fix && isString(contents)
|
97
97
|
return rtrim(contents) + "\n"
|
98
98
|
else
|
99
99
|
return contents
|
@@ -398,12 +398,11 @@ export barf = (filepath, contents='', hOptions={}) =>
|
|
398
398
|
contents = JSON.stringify(contents, null, 3)
|
399
399
|
else
|
400
400
|
assert notdefined(format), "Unknown format: #{format}"
|
401
|
-
if
|
402
|
-
contents = toBlock(contents)
|
403
|
-
else if
|
404
|
-
|
405
|
-
|
406
|
-
fs.writeFileSync(filepath, contents, {encoding: 'utf8'})
|
401
|
+
if isArrayOfStrings(contents)
|
402
|
+
contents = fixOutput(toBlock(contents))
|
403
|
+
else if isString(contents)
|
404
|
+
contents = fixOutput(contents)
|
405
|
+
fs.writeFileSync(filepath, contents)
|
407
406
|
return
|
408
407
|
|
409
408
|
# ---------------------------------------------------------------------------
|
package/src/fs.js
CHANGED
@@ -41,7 +41,8 @@ import {
|
|
41
41
|
isBoolean,
|
42
42
|
OL,
|
43
43
|
toBlock,
|
44
|
-
getOptions
|
44
|
+
getOptions,
|
45
|
+
isArrayOfStrings
|
45
46
|
} from '@jdeighan/base-utils';
|
46
47
|
|
47
48
|
import {
|
@@ -133,7 +134,7 @@ export var rmFileSync = (filepath) => {
|
|
133
134
|
|
134
135
|
// --------------------------------------------------------------------------
|
135
136
|
export var fixOutput = (contents) => {
|
136
|
-
if (fix) {
|
137
|
+
if (fix && isString(contents)) {
|
137
138
|
return rtrim(contents) + "\n";
|
138
139
|
} else {
|
139
140
|
return contents;
|
@@ -461,16 +462,13 @@ export var barf = (filepath, contents = '', hOptions = {}) => {
|
|
461
462
|
break;
|
462
463
|
default:
|
463
464
|
assert(notdefined(format), `Unknown format: ${format}`);
|
464
|
-
if (
|
465
|
-
contents = toBlock(contents);
|
466
|
-
} else if (
|
467
|
-
|
465
|
+
if (isArrayOfStrings(contents)) {
|
466
|
+
contents = fixOutput(toBlock(contents));
|
467
|
+
} else if (isString(contents)) {
|
468
|
+
contents = fixOutput(contents);
|
468
469
|
}
|
469
|
-
contents = fixOutput(contents);
|
470
470
|
}
|
471
|
-
fs.writeFileSync(filepath, contents
|
472
|
-
encoding: 'utf8'
|
473
|
-
});
|
471
|
+
fs.writeFileSync(filepath, contents);
|
474
472
|
};
|
475
473
|
|
476
474
|
// ---------------------------------------------------------------------------
|