Skip to content

Commit

Permalink
chore: sort packages after insert
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunbinseo committed Dec 15, 2023
1 parent f7c44e1 commit 924e349
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-insects-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-migrate': patch
---

chore: sort packages after insert
14 changes: 9 additions & 5 deletions packages/migrate/utils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from 'node:fs';
import path from 'node:path';
import colors from 'kleur';
import ts from 'typescript';
import MagicString from 'magic-string';
import { execFileSync, execSync } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import semver from 'semver';
import ts from 'typescript';

/** @param {string} message */
export function bail(message) {
Expand Down Expand Up @@ -244,6 +244,10 @@ export function update_pkg(content, updates) {
update_pkg(...update);
}

['dependencies', 'devDependencies'].forEach((key) => {
if (key in pkg) pkg[key] = Object.fromEntries(Object.entries(pkg[key]).sort());
});

return JSON.stringify(pkg, null, indent);
}

Expand Down Expand Up @@ -322,8 +326,8 @@ export function update_tsconfig(update_tsconfig_content) {
const file = fs.existsSync('tsconfig.json')
? 'tsconfig.json'
: fs.existsSync('jsconfig.json')
? 'jsconfig.json'
: null;
? 'jsconfig.json'
: null;
if (file) {
fs.writeFileSync(file, update_tsconfig_content(fs.readFileSync(file, 'utf8')));
}
Expand Down

0 comments on commit 924e349

Please sign in to comment.