TL;DR: Here I propose adding comb.getConfig('csscomb') method.
I spent some time playing with csscomb and node and found getting a default config file inconvenient.
Consider two examples: installing as a project dependency and globally.
var Comb = require('csscomb'),
config = require('./node_modules/csscomb/.csscomb.json'),
comb = new Comb();
comb.configure(config);
comb.processString(someString);
I find it strange that user should know where exactly to find a config file, so every time we move it to another directory (or rename it), we make a new version incompatible with a previous one.
But it’s even more amusing when the module is installed globally.
var Comb = require('csscomb');
Now what? How can I find that config file?
If I have all needed permissions and symlinks are supported, I can run npm link:
var npm = require('npm'),
config;
npm.load(function (er, npm) {
npm.commands.link('csscomb', function() {
// Now we have "a local copy" of the module:
config = require('./node_modules/csscomb/.csscomb.json');
})
});
The problem with knowing where to look is the same as with local installation.
And what if user/process doesn’t have necessary permissions?
I managed to use exec:
var exec = require('child_process').exec;
exec('which csscomb', function () {
// Use the path to go to node_modules folder
});
So many difficulties just to get one file from our package.
Why don’t we make a method like getConfig() that will make everything easy?
We can get the file by its name:
// Default one:
var config = comb.getConfig('csscomb');
// Zen from php version:
var config = comb.getConfig('zen');
Or, related to issue #102:
// Make new instance and configure in one line:
var comb = new Comb('csscomb');
TL;DR: Here I propose adding
comb.getConfig('csscomb')method.I spent some time playing with csscomb and node and found getting a default config file inconvenient.
Consider two examples: installing as a project dependency and globally.
npm install csscombI find it strange that user should know where exactly to find a config file, so every time we move it to another directory (or rename it), we make a new version incompatible with a previous one.
But it’s even more amusing when the module is installed globally.
npm install csscomb -gNow what? How can I find that config file?
If I have all needed permissions and symlinks are supported, I can run
npm link:The problem with knowing where to look is the same as with local installation.
And what if user/process doesn’t have necessary permissions?
I managed to use
exec:So many difficulties just to get one file from our package.
Why don’t we make a method like
getConfig()that will make everything easy?We can get the file by its name:
Or, related to issue #102: