Skip to content

Commit

Permalink
fix git mv commands when migrating files with $ characters (#6129)
Browse files Browse the repository at this point in the history
* use single-quote to avoid $ characters wreaking havoc - fixes #6113

* changeset

* use shell-quote package

* do this instead
  • Loading branch information
Rich-Harris authored Aug 20, 2022
1 parent 7ec22e2 commit 7eb78a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-cameras-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-migrate': patch
---

[fix] git mv files correctly when they contain \$ characters
4 changes: 2 additions & 2 deletions packages/migrate/migrations/routes/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import colors from 'kleur';
import ts from 'typescript';
import MagicString from 'magic-string';
import { execSync } from 'child_process';
import { execFileSync } from 'child_process';

/** @param {string} message */
export function bail(message) {
Expand Down Expand Up @@ -46,7 +46,7 @@ export function error(description, comment_id) {
*/
export function move_file(file, renamed, content, use_git) {
if (use_git) {
execSync(`git mv ${JSON.stringify(file)} ${JSON.stringify(renamed)}`);
execFileSync('git', ['mv', file, renamed]);
} else {
fs.unlinkSync(file);
}
Expand Down

0 comments on commit 7eb78a5

Please sign in to comment.