Skip to content
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

Merged
merged 8 commits into from
May 12, 2020

Conversation

JohannesKonings
Copy link
Contributor

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 :)

@larshp
Copy link
Member

larshp commented May 4, 2020

looks like server/src/compressed_file.ts can be deleted, the compression stuff is not triggered, and don't think its needed for this scenario

Comment on lines 146 to 164
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);
})();
});
}
}
Copy link
Contributor

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);
        })();
      });
    }
  }

Copy link
Contributor Author

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

Copy link
Contributor

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(); 

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

@JohannesKonings
Copy link
Contributor Author

@larshp I deleted everthing regarding server/src/compressed_file.ts

@larshp
Copy link
Member

larshp commented May 12, 2020

thanks, lets try this 👍

@larshp larshp merged commit 5326b64 into abaplint:master May 12, 2020
@JohannesKonings JohannesKonings deleted the dependencies branch May 12, 2020 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants