-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle dependencies from abaplint.json #60
Conversation
looks like |
server/src/handler.ts
Outdated
private async addDependencies(reg: abaplint.Registry) { | ||
const deps = this.reg.getConfig().get().dependencies; | ||
if (deps) { | ||
deps.forEach(function (dep) { | ||
(async () => { | ||
process.stderr.write("Clone: " + dep.url + "\n"); | ||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "abaplint-")); | ||
childProcess.execSync("git clone --quiet --depth 1 " + dep.url + " .", {cwd: dir, stdio: "inherit"}); | ||
const names = FileOperations.loadFileNames(dir + dep.files); | ||
let files: abaplint.IFile[] = []; | ||
files = files.concat(await FileOperations.loadFiles(false, names)); | ||
files.forEach(function (file) { | ||
reg.addFile(new abaplint.MemoryFile(file.getFilename(), file.getRaw())); | ||
}); | ||
FileOperations.deleteFolderRecursive(dir); | ||
})(); | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can leave out the function argument if you use arrow functions instead of "function" keyword:
private async addDependencies() {
const deps = this.reg.getConfig().get().dependencies;
if (deps) {
deps.forEach((dep) => {
(async () => {
process.stderr.write("Clone: " + dep.url + "\n");
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "abaplint-"));
childProcess.execSync("git clone --quiet --depth 1 " + dep.url + " .", {cwd: dir, stdio: "inherit"});
const names = FileOperations.loadFileNames(dir + dep.files);
let files: abaplint.IFile[] = [];
files = files.concat(await FileOperations.loadFiles(false, names));
files.forEach((file) => {
this.reg.addFile(new abaplint.MemoryFile(file.getFilename(), file.getRaw()));
});
FileOperations.deleteFolderRecursive(dir);
})();
});
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I changed it to the fat arrow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, now you can leave out the registry as a function argument, instead:
private async addDependencies()
and
await this.addDependencies();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully I get you right :).
I deleted the async/await.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now I get it. I removed the registry as a function argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added async/await again with leave out the registry as a function argument.
@larshp I deleted everthing regarding |
thanks, lets try this 👍 |
handle dependencies from abaplint.json #27
The most is copy paste from the abaplint CLI (https://github.com/abaplint/abaplint/blob/master/packages/cli/src/cli.ts#L87).
It works for my test case https://github.com/JohannesKonings/test-abaplint-interface.
Recommendations welcome :)