generator-begcode
Version:
Spring Boot + Angular/React/Vue in one handy generator
49 lines (48 loc) • 1.49 kB
JavaScript
import path from 'path-browserify';
export class SubWorkspace {
subpath;
workspace;
constructor(subpath, workspace) {
this.subpath = subpath;
this.workspace = workspace;
}
writeFile(subpath, data) {
return this.workspace.writeFile(this.toSubpath(subpath), data);
}
readFile(subpath) {
return this.workspace.readFile(this.toSubpath(subpath));
}
exists(subpath) {
return this.workspace.exists(this.toSubpath(subpath));
}
rename(oldPath, newPath) {
return this.workspace.rename(this.toSubpath(oldPath), this.toSubpath(newPath));
}
mkdir(subpath, opts = { recursive: false }) {
return this.workspace.mkdir(this.toSubpath(subpath), opts);
}
rmdir(subpath, opts) {
return this.workspace.rmdir(this.toSubpath(subpath), opts);
}
readdir(subpath) {
return this.workspace.readdir(this.toSubpath(subpath));
}
appendFile(subpath, data) {
return this.workspace.appendFile(this.toSubpath(subpath), data);
}
rm(subpath) {
return this.workspace.rm(this.toSubpath(subpath));
}
async exec(command, args) {
return this.workspace.exec(command, args);
}
toSubpath(subpath) {
return path.join(this.subpath, subpath);
}
writeFileSync(subpath, data) {
this.workspace.writeFileSync(subpath, data);
}
readFileSync(subpath) {
return this.workspace.readFileSync(subpath);
}
}