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

CLI interace interferes when requiring node-sass #167

Closed
kkirby opened this issue Oct 4, 2013 · 5 comments
Closed

CLI interace interferes when requiring node-sass #167

kkirby opened this issue Oct 4, 2013 · 5 comments

Comments

@kkirby
Copy link
Contributor

kkirby commented Oct 4, 2013

When requiring node-sass, the cli interface overrides the control-flow of the script.

var mSass = require('node-sass');

Upon running, this is what the output is:

JS Compiler

Options:
  --output-style     CSS output style (nested|expanded|compact|compressed)  [default: "nested"]
  --source-comments  Include debug info in output (none|normal|map)         [default: "none"]
  --include-path     Path to look for @import-ed files                      [default: "/Users/kkirby/Projects/gsTest/data"]
  --watch, -w        Watch a directory or file                            
  --output, -o       Output css file                                      
  --stdout           Print the resulting CSS to stdout                    
  --help, --help     Shows this info page.                                
  --config           The path to the application configuration file.        [default: "/Users/kkirby/Projects/gsTest/data/config.js"]

Argument check failed: function (argv){
    if (argv.help) return true;
    if (argv._.length < 1) return false;
  }

I simply commented out this line in the sass.js file:

92: exports.cli = require('./lib/cli');

And it worked.

@nschonni
Copy link
Contributor

nschonni commented Oct 4, 2013

If you're just trying to require the Sass processing, what about following the pattern here https://github.com/andrew/node-sass/blob/master/examples/middleware.js

@andrew
Copy link
Contributor

andrew commented Oct 5, 2013

I think this is a problem, people should be able to use it outside of the command line in anyway they see for with the cli getting in the way

@kkirby
Copy link
Contributor Author

kkirby commented Oct 5, 2013

Hey,

I tried to reproduce this issue on my personal computer and was unable to do so. After further investigation I found that it has to do with loading optimist twice. The project that I had, "JS Compiler", was loading Optimist as was node-sass. There are a few solutions that I can think of:

  1. Putting the optimist configuration inside of the export function. I'm not sure if this would break anything since you're exporting optimist with the configuration.
  2. Checking to see if Optimist is already loaded by looking at the Optimist object for anything pre-existing; this seems like a horrible idea since the Optimist structure can change in the future.
  3. Remove the cli include in the sass.js file. I think this is the best option since I can't find anywhere in the node-sass project that references the exported cli variable, nor is it documented. It appears that anything that uses the cli interface explicitly includes the cli file.

@andrew
Copy link
Contributor

andrew commented Oct 5, 2013

3 sounds like the best option to me, would you be up for sending it as a pull request?

@andrew andrew closed this as completed in 9867d75 Oct 5, 2013
andrew added a commit that referenced this issue Oct 5, 2013
Fixed #167 where multiple instances of Optimist would conflict.
@andrew
Copy link
Contributor

andrew commented Oct 23, 2013

Just published this as part of v0.7.0: https://github.com/andrew/node-sass/releases/tag/v0.7.0

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

No branches or pull requests

3 participants