Skip to content

Commit

Permalink
Use execFileSync instead of execSync to move files (#46796)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Nov 27, 2023
1 parent c0ef2b8 commit e2b5e39
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/content-render/scripts/reconcile-filenames-with-ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import walk from 'walk-sync'
import GithubSlugger from 'github-slugger'
import { decode } from 'html-entities'
import frontmatter from '#src/frame/lib/read-frontmatter.js'
import { execSync } from 'child_process'
import { execFileSync } from 'child_process'
import addRedirectToFrontmatter from '#src/redirects/scripts/helpers/add-redirect-to-frontmatter.js'

const slugger = new GithubSlugger()
Expand Down Expand Up @@ -60,13 +60,13 @@ contentFiles.forEach((oldFullPath) => {
const oldContentPath = path.relative(process.cwd(), oldFullPath)
const newContentPath = path.relative(process.cwd(), newFullPath)

const gitStatusOfFile = execSync(`git status --porcelain ${oldContentPath}`).toString()
const gitStatusOfFile = execFileSync('git', ['status', '--porcelain', oldContentPath]).toString()

// if file is untracked, do a regular mv; otherwise do a git mv
if (gitStatusOfFile.includes('??')) {
execSync(`mv ${oldContentPath} ${newContentPath}`)
execFileSync('git', ['mv', oldContentPath, newContentPath])
} else {
execSync(`git mv ${oldContentPath} ${newContentPath}`)
execFileSync('git', ['mv', oldContentPath, newContentPath])
}

// then add the old path to the redirect_from frontmatter
Expand Down

0 comments on commit e2b5e39

Please sign in to comment.