binhend 2.0.6 → 2.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "binhend",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "Nguyen Duc Binh",
@@ -28,9 +28,11 @@ function generate(sourceRootPath, outputRootPath, callbackDone) {
28
28
  if (fileExtension === '.css') {
29
29
  var cssModuleCode = 'binh.css(module);';
30
30
  writeToFileIfNew(fileOutputPath + '.js', cssModuleCode);
31
+ // not return here, but wait for next "if" statement to be copied to build folder, then return there.
31
32
  }
32
33
 
33
34
  if (fileExtension !== '.js') {
35
+ // any files not JS (.css, .jpg, etc.) will be copied to build folder.
34
36
  return cloneFileIfNew(fileSourcePath, fileOutputPath);
35
37
  }
36
38
 
@@ -47,6 +47,15 @@ function customRequire(filePath) {
47
47
  return this.require(filePath);
48
48
  }
49
49
 
50
+ function applyDefaultFileCSS() {
51
+ var cssModuleFile = path.parse(this.module.filename).name + '.css.js';
52
+ try {
53
+ var cssModule = this.require('./' + cssModuleFile);
54
+ css.bind(this)(cssModule);
55
+ }
56
+ catch (error) {}
57
+ }
58
+
50
59
  function css() {
51
60
  var csses = Array.from(arguments);
52
61
  var appliedStyles = this.component.options.csses;
@@ -77,6 +86,8 @@ binh.component = function(context, ui, service, style) {
77
86
  component.varname = getVariableName(component.filename);
78
87
  component.as = alias;
79
88
  component.eachChild = loopComponentChildren;
89
+
90
+ if (type === 'ui') applyDefaultFileCSS.bind(context)();
80
91
  };
81
92
 
82
93
  binh.final = function(module) {
@@ -97,24 +108,6 @@ function loopComponentChildren(callback) {
97
108
  });
98
109
  }
99
110
 
100
- binh.ui = function(module, component, htmltags, links) {
101
- binh.component({ module }, component);
102
- component.htmltags = htmltags;
103
- component.links = links;
104
- binh.final(module);
105
- };
106
-
107
- binh.service = function(module, component, links) {
108
- binh.component({ module }, null, component, null);
109
- component.links = links;
110
- binh.final(module);
111
- };
112
-
113
- binh.style = function(module, component) {
114
- binh.component({ module }, null, null, component);
115
- binh.final(module);
116
- };
117
-
118
111
  binh.css = function(module, cssFilename) {
119
112
  var cssFilePath = cssFilename && path.join(module.path, cssFilename) || module.filename.replace(/.js$/, '');
120
113
  var content = fs.readFileSync(cssFilePath, { encoding: 'utf8', flag: 'r' });