mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
build(scripts): convert to ESM
This commit is contained in:
parent
9234119d7b
commit
4881ff7ffd
3 changed files with 48 additions and 49 deletions
|
@ -1,10 +1,10 @@
|
|||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const sass = require("sass");
|
||||
const autoprefixer = require("autoprefixer");
|
||||
const postcss = require("postcss");
|
||||
// @ts-check
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import sass from "sass";
|
||||
import autoprefixer from "autoprefixer";
|
||||
import postcss from "postcss";
|
||||
|
||||
(async () => {
|
||||
const scss = fs
|
||||
.readdirSync("css")
|
||||
.filter((file) => file.endsWith(".scss") && !/^\_popover/.test(file))
|
||||
|
@ -32,4 +32,3 @@ const postcss = require("postcss");
|
|||
|
||||
fs.writeFileSync(outFile, prefixed.css);
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
const fs = require("node:fs");
|
||||
const { globSync }= require("tinyglobby");
|
||||
const { sveld } = require("sveld");
|
||||
const pkg = require("../package.json");
|
||||
// @ts-check
|
||||
import fs from "node:fs";
|
||||
import { globSync } from "tinyglobby";
|
||||
import { sveld } from "sveld";
|
||||
import pkg from "../package.json" assert { type: "json" };
|
||||
|
||||
sveld({
|
||||
glob: true,
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
|
||||
const packagePath = path.join(process.cwd(), "package.json");
|
||||
const package = JSON.parse(fs.readFileSync(packagePath, "utf8"));
|
||||
// @ts-check
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import pkg from "../package.json" assert { type: "json" };
|
||||
|
||||
/** @type {Array<keyof typeof pkg>} */
|
||||
const keys_to_remove = ["prettier", "standard-version", "devDependencies"];
|
||||
const scripts_to_keep = ["postinstall"];
|
||||
|
||||
for (const key of keys_to_remove) {
|
||||
delete package[key];
|
||||
delete pkg[key];
|
||||
}
|
||||
|
||||
if (package.scripts) {
|
||||
const preserved_scripts = {};
|
||||
/** @type {Set<keyof typeof pkg.scripts>} */
|
||||
const scripts_to_keep = new Set(["postinstall"]);
|
||||
|
||||
for (const script of scripts_to_keep) {
|
||||
if (package.scripts[script]) {
|
||||
preserved_scripts[script] = package.scripts[script];
|
||||
for (const script in pkg.scripts) {
|
||||
// @ts-ignore
|
||||
if (!scripts_to_keep.has(script)) {
|
||||
delete pkg.scripts[script];
|
||||
}
|
||||
}
|
||||
|
||||
package.scripts = preserved_scripts;
|
||||
}
|
||||
|
||||
fs.writeFileSync(packagePath, JSON.stringify(package, null, 2) + "\n");
|
||||
// Write the updated package.json file.
|
||||
const pkgPath = path.join(process.cwd(), "package.json");
|
||||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue