Skip to content
This repository
Browse code

Cleaned up lint warnings

  • Loading branch information...
commit cd60d76f2131f94cc6a651cbaa9f930c0aeca2e1 1 parent 40a7e21
Dav Glass authored April 01, 2013

Showing 1 changed file with 63 additions and 59 deletions. Show diff stats Hide diff stats

  1. 122  lib/module.js
122  lib/module.js
@@ -810,73 +810,77 @@ var buildNPM = function(json, callback) {
810 810
     if (json.npm === true) {
811 811
         json.npm = {
812 812
             name: 'yui-' + json.name
813  
-        }
  813
+        };
814 814
     }
815  
-    var name = json.npm.name || json.name;
816  
-    var builds = json.npm.builds;
  815
+    var name = json.npm.name || json.name,
  816
+        builds = json.npm.builds,
  817
+        coreBuildDir, buildDir, packageJson,
  818
+        done = function() {
  819
+            callback();
  820
+        },
  821
+        writeShim = function() {
  822
+            var shim = [
  823
+                'var yui = require("yui-core");',
  824
+                'var YUI = yui.YUI;',
  825
+                'var inst = yui.getInstance();'
  826
+            ],
  827
+                index = path.join(buildDir, 'index.js'),
  828
+                YUI, Y, loader, out, these;
  829
+
  830
+            builds.forEach(function(build) {
  831
+                var p = path.join(coreBuildDir, build, build + '.js'),
  832
+                    code = fs.readFileSync(p, 'utf8');
  833
+                console.log(p);
  834
+                shim.push('');
  835
+                shim.push('//Start' + p);
  836
+                shim.push('');
  837
+                shim.push(code);
  838
+                shim.push('');
  839
+                shim.push('//End ' + p);
  840
+                shim.push('');
  841
+            });
  842
+            shim.push('//Start Exports');
  843
+            if (json.npm.dependencies) {
  844
+                Object.keys(json.npm.dependencies).forEach(function(mod) {
  845
+                    if (mod !== 'yui-core') {
  846
+                        shim.push('require("' + mod + '");');
  847
+                    }
  848
+                });
  849
+            }
  850
+            console.log('BUILDS', builds);
  851
+            YUI = require('yui-core').YUI;
  852
+            Y = YUI();
  853
+            loader = new Y.Loader({
  854
+                ignoreRegistered: true,
  855
+                ignore: ['yui-base'],
  856
+                require: builds
  857
+            });
  858
+            out = loader.resolve(true);
  859
+            these = Y.Array.hash(builds);
  860
+            console.log(out);
  861
+            out.jsMods.forEach(function(mod) {
  862
+                if (!these[mod.name]) {
  863
+                    shim.push('require("yui-' + mod.name + '"); //From Loader');
  864
+                }
  865
+            });
  866
+            //process.exit();
  867
+            shim.push('');
  868
+            shim.push('module.exports = inst.use("' + builds.join('","') + '");');
  869
+            shim.push('');
  870
+            fs.writeFileSync(index, shim.join('\n'), 'utf8');
  871
+            done();
  872
+        };
  873
+
817 874
     if (!Array.isArray(builds)) {
818 875
         builds = Object.keys(json.builds);
819 876
     }
820 877
     delete json.npm.builds;
821 878
     log.info('Packaging ' + name + ' as an NPM module');
822  
-    var coreBuildDir = json.builds[json.name].buildDir;
823  
-    var buildDir = path.join(json.builds[json.name].buildDir + '-packages', name);
  879
+    coreBuildDir = json.builds[json.name].buildDir;
  880
+    buildDir = path.join(json.builds[json.name].buildDir + '-packages', name);
824 881
     console.log('BUILD:', buildDir);
825 882
     mkdirp.sync(buildDir);
826  
-    var done = function() {
827  
-        callback();
828  
-    };
829 883
 
830  
-    var writeShim = function() {
831  
-        var shim = [
832  
-            'var yui = require("yui-core");',
833  
-            'var YUI = yui.YUI;',
834  
-            'var inst = yui.getInstance();'
835  
-        ];
836  
-        var index = path.join(buildDir, 'index.js');
837  
-        builds.forEach(function(build) {
838  
-            var p = path.join(coreBuildDir, build, build + '.js');
839  
-            console.log(p);
840  
-            var code = fs.readFileSync(p, 'utf8');
841  
-            shim.push('');
842  
-            shim.push('//Start' + p);
843  
-            shim.push('');
844  
-            shim.push(code);
845  
-            shim.push('');
846  
-            shim.push('//End ' + p);
847  
-            shim.push('');
848  
-        });
849  
-        shim.push('//Start Exports');
850  
-        if (json.npm.dependencies) {
851  
-            Object.keys(json.npm.dependencies).forEach(function(mod) {
852  
-                if (mod !== 'yui-core') {
853  
-                    shim.push('require("' + mod + '");');
854  
-                }
855  
-            });
856  
-        }
857  
-        console.log('BUILDS', builds);
858  
-        var YUI = require('yui-core').YUI;
859  
-        var Y = YUI();
860  
-        var loader = new Y.Loader({
861  
-            ignoreRegistered: true,
862  
-            ignore: ['yui-base'],
863  
-            require: builds
864  
-        });
865  
-        var out = loader.resolve(true);
866  
-        var these = Y.Array.hash(builds);
867  
-        console.log(out);
868  
-        out.jsMods.forEach(function(mod) {
869  
-            if (!these[mod.name]) {
870  
-                shim.push('require("yui-' + mod.name + '"); //From Loader');
871  
-            }
872  
-        });
873  
-        //process.exit();
874  
-        shim.push('');
875  
-        shim.push('module.exports = inst.use("' + builds.join('","') + '");');
876  
-        shim.push('');
877  
-        fs.writeFileSync(index, shim.join('\n'), 'utf8');
878  
-        done();
879  
-    };
880 884
 
881 885
     if (exists(path.join(shifter.cwd(), 'package.json'))) {
882 886
         log.info('found a local package.json file, copying it');
@@ -884,7 +888,7 @@ var buildNPM = function(json, callback) {
884 888
             writeShim();
885 889
         });
886 890
     } else {
887  
-        var packageJson = json.npm;
  891
+        packageJson = json.npm;
888 892
         if (!packageJson.version) {
889 893
             packageJson.version = '0.0.0';
890 894
         }

0 notes on commit cd60d76

Please sign in to comment.
Something went wrong with that request. Please try again.