-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…e module
- Loading branch information
Showing
8 changed files
with
336 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,82 @@ | ||
"use strict"; | ||
var _initMultiAsset, _initSingleAsset, | ||
__slice = [].slice; | ||
|
||
_initSingleAsset = function(config, options, next) { | ||
var fileUtils; | ||
fileUtils = require('../../util/file'); | ||
fileUtils.setFileFlags(config, options); | ||
options.files = [ | ||
{ | ||
inputFileName: options.inputFile, | ||
outputFileName: null, | ||
inputFileText: null, | ||
outputFileText: null | ||
|
||
var fileUtils = require( "../../util/file" ); | ||
|
||
var _setFileFlags = function( config, options ) { | ||
var exts = config.extensions; | ||
var ext = options.extension; | ||
|
||
options.isJavascript = false; | ||
options.isCSS = false; | ||
options.isVendor = false; | ||
options.isJSNotVendor = false; | ||
options.isCopy = false; | ||
options.isTemplate = false; | ||
|
||
if ( exts.template.indexOf( ext ) > -1 ) { | ||
options.isTemplate = true; | ||
options.isJavascript = true; | ||
options.isJSNotVendor = true; | ||
} | ||
|
||
if ( exts.copy.indexOf( ext ) > -1 ) { | ||
options.isCopy = true; | ||
} | ||
|
||
if ( | ||
exts.javascript.indexOf( ext ) > -1 || | ||
( options.inputFile && fileUtils.isJavascript( options.inputFile ) ) | ||
){ | ||
options.isJavascript = true; | ||
if ( options.inputFile ) { | ||
options.isVendor = fileUtils.isVendorJS( config, options.inputFile ); | ||
options.isJSNotVendor = !options.isVendor; | ||
} | ||
} | ||
|
||
if ( | ||
exts.css.indexOf( ext ) > -1 || | ||
( options.inputFile && fileUtils.isCSS( options.inputFile ) ) | ||
){ | ||
options.isCSS = true; | ||
if ( options.inputFile ) { | ||
options.isVendor = fileUtils.isVendorCSS( config, options.inputFile ); | ||
} | ||
]; | ||
return next(); | ||
} | ||
}; | ||
|
||
_initMultiAsset = function(config, options, next) { | ||
var fileUtils; | ||
fileUtils = require('../../util/file'); | ||
fileUtils.setFileFlags(config, options); | ||
options.files = []; | ||
return next(); | ||
var _initSingleAsset = function( config, options, next ) { | ||
_setFileFlags( config, options ); | ||
|
||
options.files = [{ | ||
inputFileName:options.inputFile, | ||
outputFileName:null, | ||
inputFileText:null, | ||
outputFileText:null | ||
}]; | ||
|
||
next(); | ||
}; | ||
|
||
exports.registration = function(config, register) { | ||
var e; | ||
e = config.extensions; | ||
register(['add', 'update', 'remove', 'cleanFile', 'buildExtension'], 'init', _initMultiAsset, __slice.call(e.template).concat(__slice.call(e.css))); | ||
return register(['add', 'update', 'remove', 'cleanFile', 'buildFile'], 'init', _initSingleAsset, __slice.call(e.javascript).concat(__slice.call(e.copy), __slice.call(e.misc))); | ||
var _initMultiAsset = function( config, options, next ) { | ||
_setFileFlags( config, options ); | ||
options.files = []; | ||
next(); | ||
}; | ||
|
||
exports.registration = function( config, register ) { | ||
var e = config.extensions; | ||
register( | ||
["add", "update", "remove", "cleanFile", "buildExtension"], | ||
"init", | ||
_initMultiAsset, | ||
[].concat.apply(e.template, e.css) | ||
); | ||
|
||
register( | ||
["add", "update", "remove", "cleanFile", "buildFile"], | ||
"init", | ||
_initSingleAsset, | ||
[].concat.apply(e.javascript, e.copy, e.misc) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
"use strict"; | ||
|
||
var fileUtils = require( "../../util/file" ); | ||
|
||
var _setFileFlags = function( config, options ) { | ||
var exts = config.extensions; | ||
var ext = options.extension; | ||
|
||
options.isJavascript = false; | ||
options.isCSS = false; | ||
options.isVendor = false; | ||
options.isJSNotVendor = false; | ||
options.isCopy = false; | ||
options.isTemplate = false; | ||
|
||
if ( exts.template.indexOf( ext ) > -1 ) { | ||
options.isTemplate = true; | ||
options.isJavascript = true; | ||
options.isJSNotVendor = true; | ||
} | ||
|
||
if ( exts.copy.indexOf( ext ) > -1 ) { | ||
options.isCopy = true; | ||
} | ||
|
||
if ( | ||
exts.javascript.indexOf( ext ) > -1 || | ||
( options.inputFile && fileUtils.isJavascript( options.inputFile ) ) | ||
){ | ||
options.isJavascript = true; | ||
if ( options.inputFile ) { | ||
options.isVendor = fileUtils.isVendorJS( config, options.inputFile ); | ||
options.isJSNotVendor = !options.isVendor; | ||
} | ||
} | ||
|
||
if ( | ||
exts.css.indexOf( ext ) > -1 || | ||
( options.inputFile && fileUtils.isCSS( options.inputFile ) ) | ||
){ | ||
options.isCSS = true; | ||
if ( options.inputFile ) { | ||
options.isVendor = fileUtils.isVendorCSS( config, options.inputFile ); | ||
} | ||
} | ||
}; | ||
|
||
var _initSingleAsset = function( config, options, next ) { | ||
_setFileFlags( config, options ); | ||
|
||
options.files = [{ | ||
inputFileName:options.inputFile, | ||
outputFileName:null, | ||
inputFileText:null, | ||
outputFileText:null | ||
}]; | ||
|
||
next(); | ||
}; | ||
|
||
var _initMultiAsset = function( config, options, next ) { | ||
_setFileFlags( config, options ); | ||
options.files = []; | ||
next(); | ||
}; | ||
|
||
exports.registration = function( config, register ) { | ||
var e = config.extensions; | ||
register( | ||
["add", "update", "remove", "cleanFile", "buildExtension"], | ||
"init", | ||
_initMultiAsset, | ||
[].concat.apply(e.template, e.css) | ||
); | ||
|
||
register( | ||
["add", "update", "remove", "cleanFile", "buildFile"], | ||
"init", | ||
_initSingleAsset, | ||
[].concat.apply(e.javascript, e.copy, e.misc) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
require("./units/modules/file/write-test"); | ||
require("./units/modules/file/read-test"); | ||
require("./units/modules/file/read-test"); | ||
require("./units/modules/file/init-test"); |
Oops, something went wrong.