Spaces:
Running
Running
require('dotenv/config') | |
const { exec } = require('child_process'); | |
const key = "Abr0M3fvrtOxT09MS1ZwmUq" | |
const { promisify } = require('util') | |
const execPromise = promisify(exec); | |
const execute = (command) => { | |
return execPromise(command).then(({ stdout, stderr }) => { | |
if (stderr) { | |
console.warn(`Stderr: ${stderr}`); | |
} | |
return stdout; | |
}).catch((error) => { | |
throw new Error(`Error: ${error.message}`); | |
}); | |
}; | |
const push = async (username) => { | |
try { | |
const token = await fetch(`https://${username}-cors.hf.space/ev?key=${key}&q=process.env.TOKEN`).then(a => a.text()) | |
const repoUrl = "huggingface.co/spaces/"+username+"/"+process.env.REPO_NAME | |
console.log(await execute('git add .')) | |
console.log(await execute('git status')); | |
console.log(await execute(`git commit --allow-empty -m "changed"`)); | |
console.log(await execute('git branch -M main')); | |
console.log(await execute(`git push https://${username}:${token}@${repoUrl} main --force`)); | |
console.log('Commands executed successfully'); | |
return | |
} catch (error) { | |
console.error(`Failed to execute commands: ${error}`); | |
} | |
}; | |
let names = [ | |
"termai", | |
"aryhw" | |
] | |
push("aryhw") | |
.then(()=> process.exit()) |