Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Importer arguments #917

Open
jareware opened this issue May 1, 2015 · 8 comments
Open

Importer arguments #917

jareware opened this issue May 1, 2015 · 8 comments

Comments

@jareware
Copy link

jareware commented May 1, 2015

I'm working on a reusable (between projects) importer module for node-sass and I'd need to pass in arguments. With the node API this is of course simple, but for the CLI API I see 2 options:

  1. Using a config file that the importer will look for within its pwd
  2. Using custom CLI options, e.g. node-sass --importer=my-importer.js --myopt-foo=bar, and reading them back in through process.argv in my-importer.js

The latter would be nicer IMO (no need for extraneous files), and the CLI doesn't seem to mind options it doesn't recognize, but would there be a cleaner way that I'm just not thinking of here? Or is there a reason why the latter option just isn't an option?

@am11
Copy link
Contributor

am11 commented May 1, 2015

In my-importer.js, isn't it so that you have access to process.argv containing all the arguments passes via the actual CLI command?

@jareware
Copy link
Author

jareware commented May 1, 2015

That's... exactly what I suggested as the 2nd option. Please read on. ;)

@am11
Copy link
Contributor

am11 commented May 1, 2015

Yup, exactly what you stated and then this question confused me:

is there a reason why the latter option just isn't an option?

when we already have access to (global) process.argv array in importers.

@jareware
Copy link
Author

jareware commented May 1, 2015

Right, sure! To clarify, I was wondering whether that might be a bad idea, because for example plans on disallowing unknown CLI args (which many apps do, they'll just print the usage info). Or better yet, if someone has an even better idea for how to pass args to an importer that just hasn't occurred to me! :)

@xzyfer
Copy link
Contributor

xzyfer commented May 2, 2015

This is something we're going to need to standardise as plugin, functions
and importers gain popularity.

The first thing that cones to mind is adding node sass config into the
package.json. I see more and projects adopting this convention.
On 2 May 2015 08:43, "Jarno Rantanen" notifications@github.com wrote:

Right, sure! To clarify, I was wondering whether that might be a bad idea,
because for example plans on disallowing unknown CLI args (which many apps
do, they'll just print the usage info). Or better yet, if someone has an
even better idea for how to pass args to an importer that just hasn't
occurred to me! :)


Reply to this email directly or view it on GitHub
#917 (comment).

@jareware
Copy link
Author

jareware commented May 2, 2015

Actually I think that might be the best option for me as well, for a variety of reasons. Thanks for the input!

Feel free to close this issue, unless you want to keep it as a reminder to standardize this later on.

@am11
Copy link
Contributor

am11 commented May 2, 2015

nodeSassConfig in package.json is used in other build related scenarios as well (#743). We can standarise the nested members, for instance:

"nodeSassConfig": {
    "importerCliParams": { }
}

(the ultimate way would be to propose JSON schema: https://github.com/json-schema/json-schema)

@jareware, feel free to send the PR with a test case and README update. It is a good starting point and these things keep improving over time.

@jareware
Copy link
Author

jareware commented May 2, 2015

Well I'll first try to build it and see if it's actually convenient as well, but I'll report back. :)

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

No branches or pull requests

3 participants