From 369c356a47337a9604bd6ea164c06e223065bb02 Mon Sep 17 00:00:00 2001 From: Evgeniy Gavryushin Date: Thu, 4 Sep 2014 15:49:36 +0400 Subject: [PATCH 1/3] Move shell command to 'cli.js' --- lib/cli.js | 2 ++ lib/index.js | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 3272bc5..2a3492d 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -1,4 +1,5 @@ var path = require('path'), + shell = require('shelljs'), bench = require('./index'); module.exports = require('coa').Cmd() @@ -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)); diff --git a/lib/index.js b/lib/index.js index 1250247..3f498aa 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,5 +1,4 @@ var path = require('path'), - shell = require('shelljs'), bench = require('../.cmb/config'), fs = require('./bench-fs'), benchLogger = require('./bench-logger'), @@ -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; From d5e706fd36c47ee32acedb5ba2dce75c20e878df Mon Sep 17 00:00:00 2001 From: Evgeniy Gavryushin Date: Thu, 4 Sep 2014 15:50:05 +0400 Subject: [PATCH 2/3] Refactor the configuration of archivers --- .cmb/config.js | 2 +- lib/utils.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.cmb/config.js b/.cmb/config.js index ff69997..05b2efd 100644 --- a/.cmb/config.js +++ b/.cmb/config.js @@ -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: { diff --git a/lib/utils.js b/lib/utils.js index 449bbd9..6007d61 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -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)); }; From f6e82ad003eeaff784d8bb5a5490301e49f884dd Mon Sep 17 00:00:00 2001 From: Evgeniy Gavryushin Date: Thu, 4 Sep 2014 15:53:44 +0400 Subject: [PATCH 3/3] Update README --- README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 62eb130..9071943 100644 --- a/README.md +++ b/README.md @@ -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') @@ -80,14 +80,14 @@ 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') @@ -95,9 +95,8 @@ 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.
+ 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).