Skip to content
Browse files

Added task to check for zero length file writing

  • Loading branch information...
1 parent 3245666 commit d91bffa1467e728b27eba36c8d5760e6ec988998 @davglass committed Sep 5, 2012
Showing with 28 additions and 0 deletions.
  1. +12 −0 lib/module.js
  2. +16 −0 lib/tasks/check.js
View
12 lib/module.js
@@ -195,8 +195,10 @@ var buildCSS = function (mod, name, callback) {
stamp: '/* YUI CSS Detection Stamp */\n#yui3-css-stamp.' + name + ' { display: none; }'
})
.csslint(cssLint)
+ .check()
.write(path.join(buildDir, name, name + '.css'))
.cssmin()
+ .check()
.write(path.join(buildDir, name, name + '-min.css'))
.run(function (err, result) {
if (err) {
@@ -258,6 +260,7 @@ var buildJS = function (mod, name, callback) {
error: cacheBuild,
current: metaData[path.join(fileName, fileName + '-debug.js')]
})
+ .check()
.write(path.join(buildDir, fileName, fileName + '-debug.js'));
if (regex) {
@@ -267,11 +270,13 @@ var buildJS = function (mod, name, callback) {
}
queue.log('writing RAW file')
+ .check()
.write(path.join(buildDir, fileName, fileName + '.js'))
.log('compressing ' + path.join(fileName, fileName + '.js with ' + cName[compressorFn]));
queue[compressorFn](compressorConfig)
.log('writing -min file')
+ .check()
.write(path.join(buildDir, fileName, fileName + '-min.js'))
.run(function (err, result) {
if (err) {
@@ -300,6 +305,7 @@ var buildCoverage = function (mod, name, callback) {
charset: 'utf8',
name: 'build/' + fileName + '/' + fileName + '.js'
})
+ .check()
.log('writing coverage file')
.write(path.join(buildDir, fileName, fileName + '-coverage.js'))
.run(function (err, result) {
@@ -358,6 +364,7 @@ var buildLang = function (mod, name, callback) {
]);
queue[compressorFn](compressorConfig)
+ .check()
.write(path.join(buildDir, name, 'lang', fileName))
.run(stack.add(function (err, result) {
if (err) {
@@ -430,6 +437,7 @@ var buildSkin = function (mod, name, callback) {
stamp: '/* YUI CSS Detection Stamp */\n#yui3-css-stamp.skin-' + skinName + '-' + name + ' { display: none; }'
})
.cssmin()
+ .check()
.log('writing skin file with core wrapper')
.write(path.join(buildDir, name, 'assets', 'skins', skinName, name + '.css'))
.run(stack.add(function () {
@@ -443,6 +451,7 @@ var buildSkin = function (mod, name, callback) {
Rqueue.read([
path.join(base, name + '-skin.css')
])
+ .check()
.log('writing skin file without core wrapper')
.write(path.join(buildDir, name, 'assets', 'skins', skinName, name + '-skin.css'))
.run(stack.add(function () {
@@ -647,6 +656,7 @@ var _rollup = function (mod, name, options, callback) {
postfix: "YUI.add('" + modName + "', function (Y, NAME) {}, '@VERSION@'" + stringify(mod.config) + ");\n"
})
.log('writing rollup file ' + path.join(fileName, fileName + '-debug.js'))
+ .check()
.write(path.join(buildDir, fileName, fileName + '-debug.js'));
if (regex) {
@@ -660,10 +670,12 @@ var _rollup = function (mod, name, options, callback) {
}
queue.log('linting done, writing ' + path.join(fileName, fileName + '.js'))
+ .check()
.write(path.join(buildDir, fileName, fileName + '.js'))
.log('compressing ' + path.join(fileName, fileName + '.js with ' + cName[compressorFn]));
queue[compressorFn](compressorConfig)
+ .check()
.log('compressing done, writing ' + path.join(fileName, fileName + '-min.js'))
.write(path.join(buildDir, fileName, fileName + '-min.js'))
.run(function (err, result) {
View
16 lib/tasks/check.js
@@ -0,0 +1,16 @@
+/*
+Copyright (c) 2012, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://yuilibrary.com/license/
+*/
+
+exports.check = function (options, blob, done) {
+ var bail = null;
+
+ if (blob.result.length === 0) {
+ bail = 'writing zero length file from ' + blob.name;
+ }
+
+ done(bail, new blob.constructor(blob.result, blob));
+};
+

0 comments on commit d91bffa

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