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