Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute callback when smoosh has completed or between commands #13

Merged
merged 5 commits into from
Jan 15, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ smoosh.analyze('gzipped'); //it gzips the compressed files only
smoosh.analyze(); //which will do analyze all types
```

<code>done</code>
-------
Done is used to execute a callback at a certain point in the smoosh command chain. Typically, it is used at the end of the chain when smoosh has completed, but it can also be added between steps.

``` js
smoosh.config('smoosh.json').clean().run().build.done(function() {
console.log('Smoosh is finished!');
});
```

<code>make</code>
----
Make can currently be used as a shortcut to run all smoosh methods... It requires one argument, the path to the config file.json.
Expand Down
Empty file modified bin/smoosh
100644 → 100755
Empty file.
39 changes: 26 additions & 13 deletions lib/smoosh/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ var fs = require('fs')
, colors = require('colors')
, uglifyJs = require('uglify-js')
, jshint = require('jshint').JSHINT
, asciimo = require('asciimo').Figlet
, gzip = require('gzip')
, rimraf = require('rimraf')
, sqwish = require('sqwish');
Expand Down Expand Up @@ -30,7 +29,6 @@ function keys (obj) {
return accumulator;
}


/**
* _FILES OBJ IS FILES YOU. Yup.
*/
Expand Down Expand Up @@ -81,16 +79,17 @@ var _write = {
if (this.welcomed) return callback && callback();
this.welcomed = true;
this.newLine();
this.message('smoosh');

var font = 'Banner3',
text = 'smoosh',
that = this;
this.smoosh();
},

asciimo.write(text, font, function(art){
that._messages[1] = art.rainbow;
that.flush();
});
smoosh: function () {
this.message(' ###### ## ## ####### ####### ###### ## ##'.rainbow);
this.message('## ## ### ### ## ## ## ## ## ## ## ##'.rainbow);
this.message('## #### #### ## ## ## ## ## ## ##'.rainbow);
this.message(' ###### ## ### ## ## ## ## ## ###### #########'.rainbow);
this.message(' ## ## ## ## ## ## ## ## ## ##'.rainbow);
this.message('## ## ## ## ## ## ## ## ## ## ## ##'.rainbow);
this.message(' ###### ## ## ####### ####### ###### ## ##\n'.rainbow);
},

newLine: function () {
Expand Down Expand Up @@ -183,6 +182,8 @@ var _config = {
this.process('JAVASCRIPT');
this.process('CSS');

_write.flush();

return module.exports;
},

Expand Down Expand Up @@ -248,6 +249,7 @@ var _run = {
return module.exports;
}
this.jshint();
_write.flush();
return module.exports;
},

Expand Down Expand Up @@ -313,6 +315,8 @@ var _build = {

_write.message('\n');

_write.flush();

return module.exports;
},

Expand Down Expand Up @@ -361,7 +365,6 @@ var _build = {
},

css_compress: function (file, css) {

_files.CSS_MIN[file] = sqwish.minify(css);

fs.writeFileSync(this.getBuildPath(file, 'CSS', true), _files.CSS_MIN[file]);
Expand Down Expand Up @@ -452,6 +455,8 @@ var _analyze = {
this.process('gzipped', who);
}

_write.flush();

return module.exports;
},

Expand Down Expand Up @@ -563,6 +568,7 @@ var _get = {
}

who = who == 'all' ? false : who && who.toUpperCase();
_write.flush();
return this.getFilePaths(who);
}

Expand Down Expand Up @@ -592,6 +598,7 @@ var _API = {
rimraf.sync(_config.DIST_DIR[who])
} catch (e) {} //don't freak out if no DIST_DIR yet...
});
_write.flush();
return this;
},

Expand All @@ -603,7 +610,13 @@ var _API = {

analyze: bind(_analyze.init, _analyze),

get: bind(_get.init, _get)
get: bind(_get.init, _get),

done: function (callback) {
_write.flush();
callback && callback();
return module.exports;
}

};

Expand Down
Loading