-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathinstall.js
More file actions
45 lines (37 loc) · 1.24 KB
/
install.js
File metadata and controls
45 lines (37 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright © 2023 ThingsBoard, Inc.
*/
const fse = require('fs-extra');
const path = require('path');
let _projectRoot = null;
(async () => {
// Move the JavaScript file and its associated source map
await moveFileWithSourceMap(sourcePackage(), targetPackage());
})();
// Function to move the main package and its source map
async function moveFileWithSourceMap(sourceFilePath, targetFilePath) {
try {
// Move the main JavaScript file
await fse.move(sourceFilePath, targetFilePath, { overwrite: true });
// Check if a source map exists and move it if found
const sourceMapPath = `${sourceFilePath}.map`;
const targetMapPath = `${targetFilePath}.map`;
if (fse.pathExists(sourceMapPath)) {
await fse.move(sourceMapPath, targetMapPath, { overwrite: true });
}
} catch (err) {
console.error(`Error moving files: ${err.message}`);
}
}
function projectRoot() {
if (!_projectRoot) {
_projectRoot = __dirname;
}
return _projectRoot;
}
function sourcePackage() {
return path.join(projectRoot(), 'dist', 'widget-extension', 'system', 'thingsboard-extension-widgets.js');
}
function targetPackage() {
return path.join(projectRoot(), 'target', 'generated-resources', 'thingsboard-extension-widgets.js');
}