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

Not working with ember-auto-import & absolute input paths #69

Open
mydea opened this issue Oct 28, 2021 · 3 comments
Open

Not working with ember-auto-import & absolute input paths #69

mydea opened this issue Oct 28, 2021 · 3 comments

Comments

@mydea
Copy link

mydea commented Oct 28, 2021

I am currently trying to debug this issue:
fossasia/open-event-frontend#7971

I have a plugin that looks basically like this:

class CreateEmberL10nFastBootAssetMap extends Plugin {
  constructor(
    inputNode
  ) {
    super([inputNode], {});
  }

  build() {
    // We only support passing in one input path (for simplicity)
    this.inputPath = this.inputPaths[0];

    this.parseNode(this.inputPath);

    this.createFastBootAssetMapModule();
  }

  parseNode(inputPath) {
    let stat = this.input.statSync(inputPath);

    if (stat.isFile()) {
      this.parseFile(inputPath);
    } else if (stat.isDirectory()) {
      this.parseDirectory(inputPath);
    }
  }

  parseDirectory(inputPath) {
    let outputPath = this._getOutputPath(inputPath);
    if (!this.output.existsSync(outputPath)) {
      this.output.mkdirSync(outputPath);
    }

    let files = this.input.readdirSync(inputPath);
    files.forEach((file) => this.parseNode(path.join(inputPath, file)));
  }

  parseFile(inputPath) {
    let content = this.input.readFileSync(inputPath);
    let outputPath = this._getOutputPath(inputPath);

    // logic goes here
  }

  _getOutputPath(inputPath) {
    return path.relative(this.inputPath, inputPath);
  }
}

However, it seems that let inputPath = this.inputPaths[0]; is an absolute path to a temp directory here, e.g.:

/tmp/broccoli-3137903S9AmcZtiodI/out-0999-append_ember_auto_import_analyzer/

And this.input.readdirSync or this.input.readFileSync will convert that into e.g.

/tmp/broccoli-3137903S9AmcZtiodI/out-0999-append_ember_auto_import_analyzer//tmp/broccoli-3137903S9AmcZtiodI/out-0999-append_ember_auto_import_analyzer

Which obviously does not exist. To be honest I am not quite sure where that comes from exactly, but somewhere there seems to be a missing handling for absolute paths, I guess?

@progmatic-99
Copy link

@rwjblue Can you take a look??

@mariobehling
Copy link

Thank you for reporting this. Definitely a blocker for some or our projects too.

@mariobehling
Copy link

@rwjblue I had a look through the project history and it looks like there are not any updates for quite some time. Could you let us know, please if this project is still being continued? Thanks, appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants