@jdeighan/coffee-utils 14.0.10 → 14.0.11
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/fs.coffee +4 -8
- package/src/fs.js +5 -10
package/package.json
CHANGED
package/src/fs.coffee
CHANGED
@@ -242,17 +242,13 @@ export barf = (filepath, contents) =>
|
|
242
242
|
# ---------------------------------------------------------------------------
|
243
243
|
# withExt - change file extention in a file name
|
244
244
|
|
245
|
-
export withExt = (path, newExt
|
246
|
-
# --- Valid options:
|
247
|
-
# removeLeadingUnderScore - boolean
|
245
|
+
export withExt = (path, newExt) =>
|
248
246
|
|
249
247
|
assert newExt, "withExt(): No newExt provided"
|
250
248
|
if newExt.indexOf('.') != 0
|
251
249
|
newExt = '.' + newExt
|
252
250
|
|
253
251
|
{dir, name, ext} = pathlib.parse(path)
|
254
|
-
if hOptions.removeLeadingUnderScore && (name.indexOf('_')==0)
|
255
|
-
name = name.substr(1)
|
256
252
|
return mkpath(dir, "#{name}#{newExt}")
|
257
253
|
|
258
254
|
# ---------------------------------------------------------------------------
|
@@ -261,12 +257,12 @@ export withExt = (path, newExt, hOptions={}) =>
|
|
261
257
|
export removeFileWithExt = (path, newExt, hOptions={}) =>
|
262
258
|
# --- Valid options:
|
263
259
|
# doLog
|
264
|
-
# removeLeadingUnderScore
|
265
260
|
|
266
|
-
|
261
|
+
{doLog} = getOptions(hOptions)
|
262
|
+
fullpath = withExt(path, newExt)
|
267
263
|
try
|
268
264
|
fs.unlinkSync fullpath
|
269
|
-
if
|
265
|
+
if doLog
|
270
266
|
LOG " unlink #{filename}"
|
271
267
|
success = true
|
272
268
|
catch err
|
package/src/fs.js
CHANGED
@@ -284,32 +284,27 @@ export var barf = (filepath, contents) => {
|
|
284
284
|
|
285
285
|
// ---------------------------------------------------------------------------
|
286
286
|
// withExt - change file extention in a file name
|
287
|
-
export var withExt = (path, newExt
|
287
|
+
export var withExt = (path, newExt) => {
|
288
288
|
var dir, ext, name;
|
289
|
-
// --- Valid options:
|
290
|
-
// removeLeadingUnderScore - boolean
|
291
289
|
assert(newExt, "withExt(): No newExt provided");
|
292
290
|
if (newExt.indexOf('.') !== 0) {
|
293
291
|
newExt = '.' + newExt;
|
294
292
|
}
|
295
293
|
({dir, name, ext} = pathlib.parse(path));
|
296
|
-
if (hOptions.removeLeadingUnderScore && (name.indexOf('_') === 0)) {
|
297
|
-
name = name.substr(1);
|
298
|
-
}
|
299
294
|
return mkpath(dir, `${name}${newExt}`);
|
300
295
|
};
|
301
296
|
|
302
297
|
// ---------------------------------------------------------------------------
|
303
298
|
// removeFileWithExt - remove file with different ext
|
304
299
|
export var removeFileWithExt = (path, newExt, hOptions = {}) => {
|
305
|
-
var err, fullpath, success;
|
300
|
+
var doLog, err, fullpath, success;
|
306
301
|
// --- Valid options:
|
307
302
|
// doLog
|
308
|
-
|
309
|
-
fullpath = withExt(path, newExt
|
303
|
+
({doLog} = getOptions(hOptions));
|
304
|
+
fullpath = withExt(path, newExt);
|
310
305
|
try {
|
311
306
|
fs.unlinkSync(fullpath);
|
312
|
-
if (
|
307
|
+
if (doLog) {
|
313
308
|
LOG(` unlink ${filename}`);
|
314
309
|
}
|
315
310
|
success = true;
|