mirror of
https://github.com/noodlapp/noodl.git
synced 2026-01-11 14:52:53 +01:00
Initial commit
Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com> Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com> Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com> Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com> Co-Authored-By: Johan <4934465+joolsus@users.noreply.github.com> Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com> Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
This commit is contained in:
60
scripts/build-pack.ts
Normal file
60
scripts/build-pack.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { promisify } from 'util';
|
||||
|
||||
const readdir = promisify(fs.readdir);
|
||||
const stat = promisify(fs.stat);
|
||||
const copyFile = promisify(fs.copyFile);
|
||||
|
||||
async function copyFilesMatchingRegex(
|
||||
sourceFolder: string,
|
||||
destinationFolder: string,
|
||||
regexList: RegExp[]
|
||||
): Promise<void> {
|
||||
try {
|
||||
// Ensure the destination folder exists
|
||||
if (!fs.existsSync(destinationFolder)) {
|
||||
fs.mkdirSync(destinationFolder, { recursive: true });
|
||||
}
|
||||
|
||||
// Read the files in the source folder
|
||||
const files = await readdir(sourceFolder);
|
||||
|
||||
// Iterate through each file
|
||||
for (const file of files) {
|
||||
const filePath = path.join(sourceFolder, file);
|
||||
|
||||
// Check if it is a file
|
||||
const stats = await stat(filePath);
|
||||
if (stats.isFile()) {
|
||||
// Check if the file matches any regex in the list
|
||||
if (regexList.some((regex) => regex.test(file))) {
|
||||
// Copy the file to the destination folder
|
||||
const destinationPath = path.join(destinationFolder, file);
|
||||
await copyFile(filePath, destinationPath);
|
||||
console.log(`Copied: ${file}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Copy operation completed.');
|
||||
} catch (error) {
|
||||
console.error('Error:', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
const sourceFolder = path.join(__dirname, '..', 'packages/noodl-editor/dist');
|
||||
const destinationFolder = path.join(__dirname, '..', 'publish');
|
||||
const regexList: RegExp[] = [
|
||||
/* Windows */
|
||||
/.*Setup.*\.exe$/,
|
||||
/.*Setup.*\.blockmap$/,
|
||||
|
||||
/* MacOS */
|
||||
/.*\.dmg$/,
|
||||
/.*\.blockmap$/
|
||||
];
|
||||
|
||||
fs.mkdirSync(destinationFolder, { recursive: true });
|
||||
|
||||
copyFilesMatchingRegex(sourceFolder, destinationFolder, regexList);
|
||||
Reference in New Issue
Block a user