mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-10 02:48:33 +00:00
chore: Updated to Theia 1.31.1 (#1662)
Closes #1655 Closes #1656 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
26
scripts/sort-dependencies
Executable file
26
scripts/sort-dependencies
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Sorts the dependencies and devDependencies in the package.json without yarn.
|
||||
// Usage `./scripts/sort-dependencies ./path/to/package.json`
|
||||
|
||||
const { promises: fs } = require('fs');
|
||||
const { join, isAbsolute } = require('path');
|
||||
const arg = process.argv.slice(2).pop();
|
||||
const path = isAbsolute(arg) ? arg : join(process.cwd(), arg);
|
||||
fs.readFile(path, { encoding: 'utf8' }).then((raw) => {
|
||||
const json = JSON.parse(raw);
|
||||
['dependencies', 'devDependencies'].forEach((prop) => {
|
||||
const value = json[prop];
|
||||
if (value) {
|
||||
json[prop] = Array.from(Object.entries(value))
|
||||
.sort(([left], [right]) => left.localeCompare(right))
|
||||
.reduce((acc, [key, value]) => {
|
||||
acc[key] = value;
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
});
|
||||
fs.writeFile(path, JSON.stringify(json, null, 2) + '\n', {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user