Permalink
Browse files

Cleaned up lint warnings

  • Loading branch information...
1 parent 40a7e21 commit cd60d76f2131f94cc6a651cbaa9f930c0aeca2e1 @davglass davglass committed Apr 1, 2013
Showing with 63 additions and 59 deletions.
  1. +63 −59 lib/module.js
View
@@ -810,81 +810,85 @@ var buildNPM = function(json, callback) {
if (json.npm === true) {
json.npm = {
name: 'yui-' + json.name
- }
+ };
}
- var name = json.npm.name || json.name;
- var builds = json.npm.builds;
+ var name = json.npm.name || json.name,
+ builds = json.npm.builds,
+ coreBuildDir, buildDir, packageJson,
+ done = function() {
+ callback();
+ },
+ writeShim = function() {
+ var shim = [
+ 'var yui = require("yui-core");',
+ 'var YUI = yui.YUI;',
+ 'var inst = yui.getInstance();'
+ ],
+ index = path.join(buildDir, 'index.js'),
+ YUI, Y, loader, out, these;
+
+ builds.forEach(function(build) {
+ var p = path.join(coreBuildDir, build, build + '.js'),
+ code = fs.readFileSync(p, 'utf8');
+ console.log(p);
+ shim.push('');
+ shim.push('//Start' + p);
+ shim.push('');
+ shim.push(code);
+ shim.push('');
+ shim.push('//End ' + p);
+ shim.push('');
+ });
+ shim.push('//Start Exports');
+ if (json.npm.dependencies) {
+ Object.keys(json.npm.dependencies).forEach(function(mod) {
+ if (mod !== 'yui-core') {
+ shim.push('require("' + mod + '");');
+ }
+ });
+ }
+ console.log('BUILDS', builds);
+ YUI = require('yui-core').YUI;
+ Y = YUI();
+ loader = new Y.Loader({
+ ignoreRegistered: true,
+ ignore: ['yui-base'],
+ require: builds
+ });
+ out = loader.resolve(true);
+ these = Y.Array.hash(builds);
+ console.log(out);
+ out.jsMods.forEach(function(mod) {
+ if (!these[mod.name]) {
+ shim.push('require("yui-' + mod.name + '"); //From Loader');
+ }
+ });
+ //process.exit();
+ shim.push('');
+ shim.push('module.exports = inst.use("' + builds.join('","') + '");');
+ shim.push('');
+ fs.writeFileSync(index, shim.join('\n'), 'utf8');
+ done();
+ };
+
if (!Array.isArray(builds)) {
builds = Object.keys(json.builds);
}
delete json.npm.builds;
log.info('Packaging ' + name + ' as an NPM module');
- var coreBuildDir = json.builds[json.name].buildDir;
- var buildDir = path.join(json.builds[json.name].buildDir + '-packages', name);
+ coreBuildDir = json.builds[json.name].buildDir;
+ buildDir = path.join(json.builds[json.name].buildDir + '-packages', name);
console.log('BUILD:', buildDir);
mkdirp.sync(buildDir);
- var done = function() {
- callback();
- };
- var writeShim = function() {
- var shim = [
- 'var yui = require("yui-core");',
- 'var YUI = yui.YUI;',
- 'var inst = yui.getInstance();'
- ];
- var index = path.join(buildDir, 'index.js');
- builds.forEach(function(build) {
- var p = path.join(coreBuildDir, build, build + '.js');
- console.log(p);
- var code = fs.readFileSync(p, 'utf8');
- shim.push('');
- shim.push('//Start' + p);
- shim.push('');
- shim.push(code);
- shim.push('');
- shim.push('//End ' + p);
- shim.push('');
- });
- shim.push('//Start Exports');
- if (json.npm.dependencies) {
- Object.keys(json.npm.dependencies).forEach(function(mod) {
- if (mod !== 'yui-core') {
- shim.push('require("' + mod + '");');
- }
- });
- }
- console.log('BUILDS', builds);
- var YUI = require('yui-core').YUI;
- var Y = YUI();
- var loader = new Y.Loader({
- ignoreRegistered: true,
- ignore: ['yui-base'],
- require: builds
- });
- var out = loader.resolve(true);
- var these = Y.Array.hash(builds);
- console.log(out);
- out.jsMods.forEach(function(mod) {
- if (!these[mod.name]) {
- shim.push('require("yui-' + mod.name + '"); //From Loader');
- }
- });
- //process.exit();
- shim.push('');
- shim.push('module.exports = inst.use("' + builds.join('","') + '");');
- shim.push('');
- fs.writeFileSync(index, shim.join('\n'), 'utf8');
- done();
- };
if (exists(path.join(shifter.cwd(), 'package.json'))) {
log.info('found a local package.json file, copying it');
copyFile(path.join(shifter.cwd(), 'package.json'), path.join(buildDir, 'package.json'), function() {
writeShim();
});
} else {
- var packageJson = json.npm;
+ packageJson = json.npm;
if (!packageJson.version) {
packageJson.version = '0.0.0';
}

0 comments on commit cd60d76

Please sign in to comment.