mirror of
https://github.com/haperone/local-image-compress.git
synced 2026-07-22 06:44:26 +00:00
28 lines
990 B
JavaScript
28 lines
990 B
JavaScript
"use strict";
|
|
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const { resolveRepositoryLayout } = require("./repository-layout");
|
|
|
|
const { repositoryRoot: root } = resolveRepositoryLayout();
|
|
const buildDir = path.join(root, "build");
|
|
const releaseFiles = ["manifest.json", "main.js", "styles.css"];
|
|
|
|
fs.rmSync(buildDir, { recursive: true, force: true });
|
|
fs.mkdirSync(buildDir, { recursive: true });
|
|
|
|
for (const fileName of releaseFiles) {
|
|
const sourcePath = path.join(root, fileName);
|
|
if (!fs.existsSync(sourcePath)) {
|
|
throw new Error(`Release file is missing: ${fileName}`);
|
|
}
|
|
fs.copyFileSync(sourcePath, path.join(buildDir, fileName));
|
|
}
|
|
|
|
const stagedFiles = fs.readdirSync(buildDir).sort();
|
|
const expectedFiles = [...releaseFiles].sort();
|
|
if (JSON.stringify(stagedFiles) !== JSON.stringify(expectedFiles)) {
|
|
throw new Error(`Unexpected release contents: ${stagedFiles.join(", ")}`);
|
|
}
|
|
|
|
process.stdout.write(`Prepared release files: ${stagedFiles.join(", ")}\n`);
|