Example #1
0
var loadConfigSync = function () {
  var folder = path.dirname(this.resourcePath);
  var rcpath = rcFinder.find(folder);
  if (typeof rcpath !== 'string') {
    // No .jscsrc found.
    return {};
  }

  this.addDependency(rcpath);
  var file = fs.readFileSync(rcpath, 'utf8');
  return JSON.parse(strip(file));
};
function parse() {
  program
    .version(pkg.version)
    .option('-p, --path <path>', 'Directory of sclang and scsynth [default=/Applications/SuperCollider/SuperCollider.app/Contents/Resources]')
    .parse(process.argv);

  var opts = prefsFinder.find(process.cwd()) || {};

  if(program.path) {
    opts.path = program.path;
  }

  return opts;
}
Example #3
0
module.exports = function (config) {
    var rcfinder;

    // Check if a config file is passed and try to load it, otherwise try and find one
    if (config) {
        config = loadConfig(config);
    } else {
        rcfinder = new RcFinder('.lesshintrc', {
            loader: loadConfig
        });

        config = rcfinder.find(process.cwd());
    }

    return config;
};
Example #4
0
        function findConfiguration(file) {

// We use the synchronous version because jshint is a singleton and if two files
// are linted at the exact same time then there's no way for us to tell if an
// error happened and in what file. Linting is just a Gulp task so at the end of
// the day it doesn't even matter.

            var opts = finder.find(path.dirname(file.path));

// We change the contents before linting to add a simple return statement. This
// fixes these JSHint false positives:
//
//   * W025 (Missing name in function declaration.)
//   * W098 ('{a}' is defined but never used.)
//
// We could have whitelisted these warnings, but they can be relevant elsewhere
// in the codebase and we just need JSHint to understand our awesome build
// system.

            var str     = "return " + file.contents.toString() + ";";
            var globals = opts.globals;
            var clean   = jshint(str, opts, globals);
            var data    = extend(jshint.data(), {
                file: file.path
            });

            if (!clean) {
                stream.push({
                    opt: opts,
                    data: data,
                    errors: data.errors.map(function(error) {
                        return {
                            file: file.path,
                            error: error
                        };
                    }),
                });
            }
        }
Example #5
0
var loadConfigAsync = function (callback) {
  var folder = path.dirname(this.resourcePath);
  rcFinder.find(folder, function (err, rcpath) {
    if (typeof rcpath !== 'string') {
      // No .jscsrc found.
      return callback(null, {});
    }

    this.addDependency(rcpath);
    fs.readFile(rcpath, 'utf8', function (err, file) {
      var options;

      if (!err) {
        try {
          options = JSON.parse(strip(file));
        }
        catch (e) {
          err = e;
        }
      }
      callback(err, options);
    });
  }.bind(this));
};