@gooin/garmin-connect
Version:
Makes it simple to interface with Garmin Connect to get or set any data point
37 lines • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeToFile = exports.createDirectory = exports.checkIsDirectory = void 0;
const node_fs_1 = require("node:fs");
const checkIsDirectory = async (filePath) => {
try {
const stats = await node_fs_1.promises.lstat(filePath);
return stats.isDirectory();
}
catch (error) {
if (error.code === 'ENOENT') {
// 文件或目录不存在
return false;
}
throw error;
}
};
exports.checkIsDirectory = checkIsDirectory;
const createDirectory = async (directoryPath) => {
try {
await node_fs_1.promises.mkdir(directoryPath, { recursive: true });
}
catch (error) {
throw error;
}
};
exports.createDirectory = createDirectory;
const writeToFile = async (filePath, data) => {
try {
await node_fs_1.promises.writeFile(filePath, data);
}
catch (error) {
throw error;
}
};
exports.writeToFile = writeToFile;
//# sourceMappingURL=utils.js.map