Created Dockerization option; created src folder; reated requirements.txt
This commit is contained in:
46
src/paths-utility.js
Normal file
46
src/paths-utility.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const path = require("path");
|
||||
const {URI} = require("vscode-uri");
|
||||
|
||||
|
||||
|
||||
function makeServerPath(fileName, replacement) {
|
||||
if (fileName.startsWith("file:")) {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
const serverPath = formatPath(__dirname + path.sep + "temp" + path.sep + fileName);
|
||||
if (replacement) {
|
||||
return serverPath.replace(
|
||||
replacement.from,
|
||||
replacement.to
|
||||
);
|
||||
}
|
||||
|
||||
return serverPath;
|
||||
}
|
||||
|
||||
function makeClientPath(filePath, replacement) {
|
||||
if (/^(file|https?):/.test(filePath)) {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
const clientPath = filePath.split(/[/\\]/).pop();
|
||||
if (replacement) {
|
||||
return clientPath.replace(
|
||||
replacement.from,
|
||||
replacement.to
|
||||
);
|
||||
}
|
||||
|
||||
return clientPath;
|
||||
}
|
||||
|
||||
function formatPath(filePath) {
|
||||
return URI.file(filePath).toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
exports.formatPath = formatPath;
|
||||
exports.makeClientPath = makeClientPath;
|
||||
exports.makeServerPath = makeServerPath;
|
||||
Reference in New Issue
Block a user