1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const AbstractScriptedFlushable_1 = require("../../internal/common/AbstractScriptedFlushable");
|
4 |
|
5 |
|
6 |
|
7 | class AbstractFile extends AbstractScriptedFlushable_1.AbstractScriptedFlushable {
|
8 | get name() {
|
9 | return this.path.split("/").pop();
|
10 | }
|
11 | get extension() {
|
12 | return this.name.includes(".") ?
|
13 | this.name.split(".").pop() :
|
14 | "";
|
15 | }
|
16 | rename(name) {
|
17 | return this.setPath(this.path.replace(new RegExp(`${this.name}$`), name));
|
18 | }
|
19 | replace(re, replacement) {
|
20 | return this.getContent()
|
21 | .then(content => this.setContent(content.replace(re, replacement)));
|
22 | }
|
23 | replaceAll(oldLiteral, newLiteral) {
|
24 | return this.getContent()
|
25 | .then(content => this.setContent(content.split(oldLiteral).join(newLiteral)));
|
26 | }
|
27 | }
|
28 | exports.AbstractFile = AbstractFile;
|
29 |
|
\ | No newline at end of file |