Skip to content

Commit

Permalink
Merge pull request #14 from eGavr/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
eGavr committed Sep 4, 2014
2 parents 5464cea + f6e82ad commit f99a611
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .cmb/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
},
// each method is the imitation of the usage of some archiver
archivers: {
gzip: archive('gzip -k [FILE_PATH] && mv [FILE_PATH].gz [TO_ARCH_CSS]', '.gz')
gzip: archive('gzip -k [FILE_PATH]', '.gz')
},
// input and output
paths: {
Expand Down
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ Options:

### How to configure paths?

Go to the [configuration file](https://github.com/eGavr/css-minimizers-benchmark/blob/master/.cmb/config.js#L20). In this file you can configure paths with the help of these variables:
Go to the [configuration file](https://github.com/eGavr/css-minimizers-benchmark/blob/master/.cmb/config.js#L19). In this file you can configure paths with the help of these variables:

* `toRawCSS` - path to tests (raw, not minimized **CSS** files).
* `toMinCSS` - path where to output minimized **CSS** files.
* `toArchCSS` - path where to output archived **CSS** files.
* `toRawCSS` - the path to tests raw, not minimized **CSS** files.
* `toMinCSS` - the path where to output minimized **CSS** files.
* `toArchCSS` - the path where to output archived **CSS** files.

### How to add your minimizer?

**1**. Go to the [package.json](https://github.com/eGavr/css-minimizers-bench/blob/master/package.json#L27) and add your minimizer to the dependencies.

**2**. Go to the [configuration file](https://github.com/eGavr/css-minimizers-benchmark/blob/master/.cmb/config.js#L9) and add your code according to the following template:
**2**. Go to the [configuration file](https://github.com/eGavr/css-minimizers-benchmark/blob/master/.cmb/config.js#L8) and add your code according to the following template:

```js
name: minimize(require('module'), 'method')
Expand All @@ -80,24 +80,23 @@ where:
**3**. Reinstall the dependencies.

```bash
npm install
$ npm install
```

**4**. See the [usage](https://github.com/eGavr/css-minimizers-bench#usage).

### How to add your archiver?

**1**. Go to the [configuration file](https://github.com/eGavr/css-minimizers-benchmark/blob/master/.cmb/config.js#L16) and add your code according to the following template:
**1**. Go to the [configuration file](https://github.com/eGavr/css-minimizers-benchmark/blob/master/.cmb/config.js#L15) and add your code according to the following template:

```js
name: archive('bash script', 'suffix')
```

where:
* `name` - the name of your archiver (it will be used in the log).
* `bash script` which archives the file. This script provides several **keywords**:
* `[FILE_PATH]` will be replaced with the paths of all files which were minimized by all specified in the [configuration file](https://github.com/eGavr/css-minimizers-bench/blob/master/.cmb/config.js#L9) minimizers.
* `[TO_ARCH_CSS]` will be replaced with the path which you have specified in variable `paths.toArchCSS` in the [configuration file](https://github.com/eGavr/css-minimizers-bench/blob/master/.cmb/config.js#L23).
* `bash script` which archives the file.<br>
This script provides **keyword** `[FILE_PATH]`. When you run the benchmark, it will be replaced with the paths of all files which were minimized by all specified in the [configuration file](https://github.com/eGavr/css-minimizers-bench/blob/master/.cmb/config.js#L8) minimizers.
* `suffix` which is added to a file by the archiver.

**2**. See the [usage](https://github.com/eGavr/css-minimizers-bench#usage).
Expand Down
2 changes: 2 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var path = require('path'),
shell = require('shelljs'),
bench = require('./index');

module.exports = require('coa').Cmd()
Expand All @@ -22,6 +23,7 @@ module.exports = require('coa').Cmd()
.short('o').long('output')
.end()
.act(function (opts) {
shell.exec('ulimit -n 8192');
bench.compare(opts);
})
.run(process.argv.slice(2));
3 changes: 0 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var path = require('path'),
shell = require('shelljs'),
bench = require('../.cmb/config'),
fs = require('./bench-fs'),
benchLogger = require('./bench-logger'),
Expand All @@ -24,8 +23,6 @@ function addSymbols(interval, nameLen, symbol) {
exports.compare = function (options) {
var outputToFile = options.output;

shell.exec('ulimit -n 8192');

// constants
var MAX_TIME = Number.MAX_VALUE;

Expand Down
2 changes: 2 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ function archive(command, fileSuffix) {

benchLogger('i', '[a] Exec bash script --> ', _command);

shell.exec('ulimit -n 8192');
shell.exec(_command);
shell.mv('-f', filePath + fileSuffix, toArchCSS);

return fs.getFileSize(path.join(toArchCSS, fileName + fileSuffix));
};
Expand Down

0 comments on commit f99a611

Please sign in to comment.