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

rootpath does nothing #220

Open
aharris opened this issue Sep 10, 2020 · 2 comments
Open

rootpath does nothing #220

aharris opened this issue Sep 10, 2020 · 2 comments

Comments

@aharris
Copy link

aharris commented Sep 10, 2020

Example:

inlineSource(path, {
    rootpath: 'fofdsafndsgnsfdlkjgfjndlksgjno'
  })
    .then((html) => {
      // Do something with html
      console.log('html: ', html);
    })
    .catch((err) => {
      console.log('err: ', err);
      // Handle error
    });

We pass it into the context but it doesn't look like anything happens with it:

 const ctx = context.create(options);

    console.log('ctx: ', ctx.rootpath); // This has the correct path

    // Load html content
    if (isFilepath(htmlpath)) {
      ctx.htmlpath = path.resolve(htmlpath);
      try {
        ctx.html = ctx.fs.readFileSync(ctx.htmlpath, 'utf8');
      } catch (err) {
        return reject(err);
      }
      // Passed file content instead of path
    } else {
      ctx.html = htmlpath;
    }
@popeindustries
Copy link
Owner

rootpath is used to resolve relative src/rel from the html file content, not the actual path to the html file for processing.

@aharris
Copy link
Author

aharris commented Sep 13, 2020

Yes. But it does not change the path of the the Intended import file so the import fails as not found.

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

2 participants