Spaces:
Running
Running
File size: 1,150 Bytes
c5bf270 cbf9bc3 2bcac81 c5bf270 426c6b5 c5bf270 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
require('dotenv/config')
const { exec } = require('child_process');
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 = process.env.TOKEN;
const repoUrl = "huggingface.co/spaces/"+username+"/"+process.env.REPO_NAME
console.log(await execute('git config --global --add safe.directory /app'))
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}`);
}
};
push("termai")
.then(()=> process.exit()) |