1"use strict"; 2 3Object.defineProperty(exports, "__esModule", { 4 value: true 5}); 6exports.copyFilePathToPathAsync = copyFilePathToPathAsync; 7exports.removeFile = removeFile; 8 9function _fs() { 10 const data = _interopRequireDefault(require("fs")); 11 12 _fs = function () { 13 return data; 14 }; 15 16 return data; 17} 18 19function _path() { 20 const data = _interopRequireDefault(require("path")); 21 22 _path = function () { 23 return data; 24 }; 25 26 return data; 27} 28 29function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 30 31/** A basic function that copies a single file to another file location. */ 32async function copyFilePathToPathAsync(src, dest) { 33 const srcFile = await _fs().default.promises.readFile(src); 34 await _fs().default.promises.mkdir(_path().default.dirname(dest), { 35 recursive: true 36 }); 37 await _fs().default.promises.writeFile(dest, srcFile); 38} 39/** Remove a single file (not directory). Returns `true` if a file was actually deleted. */ 40 41 42function removeFile(filePath) { 43 try { 44 _fs().default.unlinkSync(filePath); 45 46 return true; 47 } catch (error) { 48 // Skip if the remove did nothing. 49 if (error.code === 'ENOENT') { 50 return false; 51 } 52 53 throw error; 54 } 55} 56//# sourceMappingURL=fs.js.map