UNPKG

@sebastienrousseau/dotfiles

Version:

Dotfiles - A set of macOS / Linux and Windows configuration files - Simply designed to fit your shell life.

2 lines (1 loc) 675 B
import fs from"fs";import os from"os";import path from"path";import{dotfile,version}from"./constants.js";import{promisify}from"util";const destPath=path.resolve(__dirname,os.homedir()+"/dotfiles_backup/");const https=require("https");const mv=promisify(fs.rename);const download=async()=>{const file=fs.createWriteStream(version);const request=https.get(dotfile,(response)=>{response.pipe(file);file.on("finish",async()=>{file.close();try{await mv(version,`${destPath}/${version}`);fs.rmSync(version);}catch(err){console.error("Error during file download:",err);}});});request.on("error",(err)=>{console.error("Error during file download:",err);});};export default download;