compile-hero
compile-hero copied to clipboard
variable support settings.json
Support for "-output-directory" for $ {folderPath} and $ {workspaceFolder} variables can be added.
Support for "-output-directory" for $ {folderPath} and $ {workspaceFolder} variables can be added.
This is a good suggestion, but at present the underlying layer of vscode
does not seem to support this feature. I will consider improving it and let vscode support
this feature.
Hello there, It can help the following code example.
export const readFileName = async ({ fileName, selectedText }: { fileName: string; selectedText?: string }) => {
let workspaceRootPath = vscode.workspace.rootPath;
+let fileWorkspaceFolder = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0] : undefined;
let fileSuffix: FileSuffix = fileType(fileName);
.
.
.
.
.
.
let compileOptions: CompileOptions = {
generateMinifiedHtml: config.get<boolean>("generate-minified-html"),
generateMinifiedCss: config.get<boolean>("generate-minified-css"),
generateMinifiedJs: config.get<boolean>("generate-minified-javascript"),
};
if (!compileStatus[fileSuffix]) return;
+ let veriableError: string;
+ if (outputDirectoryPath[fileSuffix].indexOf("}/") < 0 &&
(outputDirectoryPath[fileSuffix].length - outputDirectoryPath[fileSuffix].indexOf("}")) > 1) {
+ veriableError = fileSuffix + "; '/' must be used at the end of the variable or '}' must be the last character.";
+ vscode.window.showErrorMessage(veriableError);
+ return;
+ } else if (outputDirectoryPath[fileSuffix].indexOf("${workspaceFolder}") >= 0) {
+ outputDirectoryPath[fileSuffix] = outputDirectoryPath[fileSuffix].replace("${workspaceFolder}", String(fileWorkspaceFolder?.uri.fsPath));
+ } else if (outputDirectoryPath[fileSuffix].indexOf("${folderPath}") >= 0) {
+ outputDirectoryPath[fileSuffix] = outputDirectoryPath[fileSuffix].replace("${folderPath}", String(fileWorkspaceFolder?.uri.fsPath));
+ } else if (outputDirectoryPath[fileSuffix].indexOf("$") >= 0) {
+ let findStartNumber: number = outputDirectoryPath[fileSuffix].indexOf("$");
+ let findEndNumber: number;
+ if (outputDirectoryPath[fileSuffix].indexOf("}") < 0) {
+ if (outputDirectoryPath[fileSuffix].indexOf("/") < 0) {
+ findEndNumber = outputDirectoryPath[fileSuffix].length;
+ } else {
+ findEndNumber = outputDirectoryPath[fileSuffix].indexOf("/");
+ }
+ } else {
+ findEndNumber = outputDirectoryPath[fileSuffix].indexOf("}");
+ }
+ findEndNumber++;
+ console.log(outputDirectoryPath[fileSuffix].indexOf("}"));
+ veriableError = fileSuffix + "; Output directory unsupported variable: " +
outputDirectoryPath[fileSuffix].slice(findStartNumber, findEndNumber);
+ vscode.window.showErrorMessage(veriableError);
+ return;
+ }
let outputPath = path.resolve(fileName, "../", outputDirectoryPath[fileSuffix]);
Thank you very much for your code ideas, you can submit it in the pull request, if merge successful, I will add your name in the contributor column.