1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.Workdir = void 0;
|
4 | const instruction_1 = require("../instruction");
|
5 | class Workdir extends instruction_1.Instruction {
|
6 | constructor(document, range, dockerfile, escapeChar, instruction, instructionRange) {
|
7 | super(document, range, dockerfile, escapeChar, instruction, instructionRange);
|
8 | }
|
9 | |
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | getPath() {
|
18 | return this.getArgumentsContent();
|
19 | }
|
20 | |
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | getAbsolutePath() {
|
32 | const path = this.getPath();
|
33 | if (path === null || path.startsWith("/")) {
|
34 | return path;
|
35 | }
|
36 | const startLine = this.getRange().start.line;
|
37 | const hierarchy = this.dockerfile.getStageHierarchy(startLine);
|
38 | for (let i = hierarchy.length - 1; i >= 0; i--) {
|
39 | const workdirs = hierarchy[i].getWORKDIRs();
|
40 | for (let j = workdirs.length - 1; j >= 0; j--) {
|
41 | if (workdirs[j].getRange().start.line < startLine) {
|
42 | const parent = workdirs[j].getAbsolutePath();
|
43 | if (parent === undefined || parent === null) {
|
44 | return undefined;
|
45 | }
|
46 | return parent.endsWith("/") ? parent + path : parent + "/" + path;
|
47 | }
|
48 | }
|
49 | }
|
50 | return undefined;
|
51 | }
|
52 | }
|
53 | exports.Workdir = Workdir;
|