1 | "use strict";
|
2 | var __importStar = (this && this.__importStar) || function (mod) {
|
3 | if (mod && mod.__esModule) return mod;
|
4 | var result = {};
|
5 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
6 | result["default"] = mod;
|
7 | return result;
|
8 | };
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | const BroccoliPlugin = require("broccoli-plugin");
|
11 | const path = require("path");
|
12 | const fs = __importStar(require("fs-extra"));
|
13 | const tmp = require("tmp");
|
14 |
|
15 | const ensureSymlink = require("ensure-symlink");
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | class BroccoliSymbolicLinker extends BroccoliPlugin {
|
22 | constructor(fileMap, options = {}) {
|
23 | let pluginOpts = { needsCache: false };
|
24 | Object.assign(pluginOpts, options);
|
25 | super([], pluginOpts);
|
26 | this.files = Object.assign({}, fileMap);
|
27 | }
|
28 | reset(fileMap) {
|
29 | this.files = Object.assign({}, fileMap);
|
30 | }
|
31 | |
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | ln_s(src, dest) {
|
45 | this.files[dest] = src;
|
46 | let tartgetDir = this.outputPath;
|
47 | if (!tartgetDir) {
|
48 | this.fakeOutputPath = this.fakeOutputPath || tmp.dirSync().name;
|
49 | tartgetDir = this.fakeOutputPath;
|
50 | }
|
51 | return path.join(tartgetDir, dest);
|
52 | }
|
53 | |
54 |
|
55 |
|
56 | numberOfFiles() {
|
57 | return Object.keys(this.files).length;
|
58 | }
|
59 | |
60 |
|
61 |
|
62 | build() {
|
63 |
|
64 |
|
65 | for (let dest of Object.keys(this.files)) {
|
66 | let src = this.files[dest];
|
67 |
|
68 | dest = path.join(this.outputPath, dest);
|
69 | let dir = path.dirname(dest);
|
70 | fs.mkdirpSync(dir);
|
71 | ensureSymlink(src, dest);
|
72 | }
|
73 | }
|
74 | |
75 |
|
76 |
|
77 | debug() {
|
78 | return Object.keys(this.files).join("\n");
|
79 | }
|
80 | }
|
81 | exports.BroccoliSymbolicLinker = BroccoliSymbolicLinker;
|
82 |
|
\ | No newline at end of file |