Skip to content

Commit

Permalink
v0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvianen committed Jan 2, 2024
1 parent 9644b5b commit b34120e
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 101 deletions.
49 changes: 19 additions & 30 deletions dist/js/class/DirectoryCleaner.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
"use strict";
// class/DirectoryCleaner.ts
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Expand All @@ -26,8 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
// ============================================================================
// Import
// ============================================================================
const fs_1 = require("fs");
const path_1 = __importDefault(require("path"));
var fs_1 = require("fs");
var path_1 = __importDefault(require("path"));
// ============================================================================
// Classes
// ============================================================================
Expand All @@ -36,27 +27,25 @@ class DirectoryCleaner {
* Recursively deletes all contents of the directory asynchronously.
* @param dirPath The path to the directory to clean.
*/
cleanDirectory(dirPath) {
return __awaiter(this, void 0, void 0, function* () {
try {
const files = yield fs_1.promises.readdir(dirPath);
for (const file of files) {
const curPath = path_1.default.join(dirPath, file);
const stat = yield fs_1.promises.lstat(curPath);
if (stat.isDirectory()) {
yield this.cleanDirectory(curPath);
}
else {
yield fs_1.promises.unlink(curPath);
}
async cleanDirectory(dirPath) {
try {
const files = await fs_1.promises.readdir(dirPath);
for (const file of files) {
const curPath = path_1.default.join(dirPath, file);
const stat = await fs_1.promises.lstat(curPath);
if (stat.isDirectory()) {
await this.cleanDirectory(curPath);
}
else {
await fs_1.promises.unlink(curPath);
}
yield fs_1.promises.rmdir(dirPath);
}
catch (error) {
console.error(`Error cleaning directory ${dirPath}: ${error}`);
throw error; // Rethrow the error for further handling if necessary
}
});
await fs_1.promises.rmdir(dirPath);
}
catch (error) {
console.error(`Error cleaning directory ${dirPath}: ${error}`);
throw error; // Rethrow the error for further handling if necessary
}
}
}
// ============================================================================
Expand Down
59 changes: 23 additions & 36 deletions dist/js/class/DirectoryCopier.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
"use strict";
// class/DirectoryCopier.ts
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Expand All @@ -26,8 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
// ============================================================================
// Import
// ============================================================================
const path_1 = __importDefault(require("path"));
const fs_1 = require("fs");
var path_1 = __importDefault(require("path"));
var fs_1 = require("fs");
// ============================================================================
// Classes
// ============================================================================
Expand All @@ -41,37 +32,33 @@ class DirectoryCopier {
* @param destDir The destination directory path.
* @throws Will throw an error if copying fails for any file or directory.
*/
copyFiles(srcDir, destDir) {
return __awaiter(this, void 0, void 0, function* () {
try {
const resolvedSrcDir = path_1.default.resolve(srcDir);
const resolvedDestDir = path_1.default.resolve(destDir);
yield this.recursiveCopy(resolvedSrcDir, resolvedDestDir);
console.log(`Files copied from ${resolvedSrcDir} to ${resolvedDestDir}`);
}
catch (error) {
console.error('Error copying files:', error);
throw error;
}
});
async copyFiles(srcDir, destDir) {
try {
const resolvedSrcDir = path_1.default.resolve(srcDir);
const resolvedDestDir = path_1.default.resolve(destDir);
await this.recursiveCopy(resolvedSrcDir, resolvedDestDir);
console.log(`Files copied from ${resolvedSrcDir} to ${resolvedDestDir}`);
}
catch (error) {
console.error('Error copying files:', error);
throw error;
}
}
/**
* Recursively copies files and directories.
* @param srcDir Source directory.
* @param destDir Destination directory.
*/
recursiveCopy(srcDir, destDir) {
return __awaiter(this, void 0, void 0, function* () {
yield fs_1.promises.mkdir(destDir, { recursive: true });
const entries = yield fs_1.promises.readdir(srcDir, { withFileTypes: true });
for (let entry of entries) {
const srcPath = path_1.default.join(srcDir, entry.name);
const destPath = path_1.default.join(destDir, entry.name);
entry.isDirectory() ?
yield this.recursiveCopy(srcPath, destPath) :
yield fs_1.promises.copyFile(srcPath, destPath);
}
});
async recursiveCopy(srcDir, destDir) {
await fs_1.promises.mkdir(destDir, { recursive: true });
const entries = await fs_1.promises.readdir(srcDir, { withFileTypes: true });
for (let entry of entries) {
const srcPath = path_1.default.join(srcDir, entry.name);
const destPath = path_1.default.join(destDir, entry.name);
entry.isDirectory() ?
await this.recursiveCopy(srcPath, destPath) :
await fs_1.promises.copyFile(srcPath, destPath);
}
}
}
// ============================================================================
Expand Down
37 changes: 13 additions & 24 deletions dist/js/class/DirectoryCreator.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
"use strict";
// class/DirectoryGenerator.ts
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Expand All @@ -26,8 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
// ============================================================================
// Import
// ============================================================================
const fs_1 = require("fs");
const path_1 = __importDefault(require("path"));
var fs_1 = require("fs");
var path_1 = __importDefault(require("path"));
// ============================================================================
// Classes
// ============================================================================
Expand All @@ -46,20 +37,18 @@ class DirectoryCreator {
* available before performing file operations.
* @throws Will throw an error if directory creation fails.
*/
createDirectories(basePath, directories) {
return __awaiter(this, void 0, void 0, function* () {
try {
for (const dir of directories) {
const dirPath = path_1.default.join(basePath, dir);
yield fs_1.promises.mkdir(dirPath, { recursive: true });
console.log(`Directory created or already exists: ${dirPath}`);
}
}
catch (error) {
console.error(`Error creating directories: ${error}`);
throw error;
async createDirectories(basePath, directories) {
try {
for (const dir of directories) {
const dirPath = path_1.default.join(basePath, dir);
await fs_1.promises.mkdir(dirPath, { recursive: true });
console.log(`Directory created or already exists: ${dirPath}`);
}
});
}
catch (error) {
console.error(`Error creating directories: ${error}`);
throw error;
}
}
}
// ============================================================================
Expand Down
6 changes: 3 additions & 3 deletions dist/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ exports.DirectoryCreator = exports.DirectoryCopier = exports.DirectoryCleaner =
// Import
// ============================================================================
// Import | Utility Classes
const DirectoryCleaner_1 = __importDefault(require("./class/DirectoryCleaner"));
var DirectoryCleaner_1 = __importDefault(require("./class/DirectoryCleaner"));
exports.DirectoryCleaner = DirectoryCleaner_1.default;
const DirectoryCopier_1 = __importDefault(require("./class/DirectoryCopier"));
var DirectoryCopier_1 = __importDefault(require("./class/DirectoryCopier"));
exports.DirectoryCopier = DirectoryCopier_1.default;
const DirectoryCreator_1 = __importDefault(require("./class/DirectoryCreator"));
var DirectoryCreator_1 = __importDefault(require("./class/DirectoryCreator"));
exports.DirectoryCreator = DirectoryCreator_1.default;
6 changes: 3 additions & 3 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pack.gl",
"version": "0.0.3",
"version": "0.0.5",
"description": "Package Builder.",
"keywords": [
"pack.gl",
Expand All @@ -11,8 +11,8 @@
],
"license": "Apache-2.0",
"homepage": "https://www.pack.gl/",
"main": "js/index.js",
"types": "js/index.d.ts",
"main": "js/index",
"types": "js/index",
"files": [
"svg/**/*.svg",
"js/**/*.{js,map}",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pack.gl",
"description": "Package Builder.",
"version": "0.0.3",
"version": "0.0.5",
"config": {
"version_short": "0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions script/js/config/package.config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion script/js/config/package.config.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions script/js/config/ts.config.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
declare const tsConfig: {
target: string;
module: string;
allowSyntheticDefaultImports: boolean;
esModuleInterop: boolean;
declaration: boolean;
strict: boolean;
skipLibCheck: boolean;
forceConsistentCasingInFileNames: boolean;
resolveJsonModule: boolean;
lib: string[];
};
export default tsConfig;
6 changes: 6 additions & 0 deletions script/js/config/ts.config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion script/js/config/ts.config.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b34120e

Please sign in to comment.