Commit dce50715 authored by Aral Balkan's avatar Aral Balkan
Browse files

Make build backup and restore the .gitignore file in dist

parent 697c4d0d
......@@ -37,6 +37,9 @@ const distGitBackupDirectoryPath = path.resolve('..', distGitBackupDirectoryName
const distOldGitBackupDirectoryName = `${distGitBackupDirectoryName}.old`
const distOldGitBackupDirectoryPath = path.resolve('..', distOldGitBackupDirectoryName)
const gitIgnoreFilePath = path.join(distDirectoryPath, '.gitignore')
const gitIgnoreFile = fs.readFileSync(gitIgnoreFilePath, 'utf-8')
// Exec with promises and piped stdout.
async function exec(command) {
const commandPromise = _exec(command)
......@@ -85,6 +88,10 @@ if (fs.existsSync(distGitBackupDirectoryPath)) {
// Back up the git folder so it’s not nuked by the Snowpack build.
console.log('Restoring .git folder into distribution directory.')
await exec(`cp -R ${distGitBackupDirectoryPath} ${distDirectoryGitPath}`, { env: process.env })
// And save the previously-backed up .gitignore file also.
console.log('Restoring .gitignore file.')
fs.writeFileSync(gitIgnoreFilePath, gitIgnoreFile, 'utf-8')
} else {
console.log(' - Distribution directory not under version control; no .git directory to restore.')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment