From ceeae08038f8699b59a6794d607f870db657963b Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Wed, 25 May 2016 19:18:22 -0400 Subject: [PATCH 1/3] added penthouse timeout option --- .nvmrc | 1 + README.md | 4 ++++ cli.js | 4 ++++ lib/core.js | 1 + test/02-generate.js | 16 ++++++++++++++++ 5 files changed, 26 insertions(+) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..2bf5ad04 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +stable diff --git a/README.md b/README.md index 919a4adc..7a97591a 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,9 @@ critical.generate({ // Extract inlined styles from referenced stylesheets extract: true, + // Complete Timeout for Operation + timeout: 30000, + // Prefix for asset directory pathPrefix: '/MySubfolderDocrot', @@ -219,6 +222,7 @@ critical.generate({ | inlineImages | `boolean` | `false` | Inline images | assetPaths | `array` | `[]` | List of directories/urls where the inliner should start looking for assets | maxImageFileSize | `integer` | `10240`| Sets a max file size (in bytes) for base64 inlined images +| timeout | `integer` | `30000`| Sets a maximum timeout for the operation | pathPrefix | `string` | `/` | Path to prepend CSS assets with. You *must* make this path absolute if you are going to be using critical in multiple target files in disparate directory depths. (eg. targeting both `/index.html` and `/admin/index.html` would require this path to start with `/` or it wouldn't work.) | include | `array` | `[]` | Force include css rules. See [`penthouse#usage`](https://github.com/pocketjoso/penthouse#usage-1). | ignore | `array` | `[]` | Ignore css rules. See [`filter-css`](https://github.com/bezoerb/filter-css) for usage examples. diff --git a/cli.js b/cli.js index 3b9939e9..979f2bac 100755 --- a/cli.js +++ b/cli.js @@ -29,6 +29,7 @@ var help = [ ' --include RegExp, @type or selector to include', ' --maxFileSize Sets a max file size (in bytes) for base64 inlined images', ' --assetPaths Directories/Urls where the inliner should start looking for assets.', + ' --timeout Sets the maximum timeout (in milliseconds) for the operation (defaults to 30000 ms).', ' ----------------------------------------------------------------------.', ' Deprecated - use "--inline" to retrieve the modified HTML', ' critical source.html --inline > dest.html', @@ -81,6 +82,9 @@ cli.flags = _.reduce(cli.flags, function (res, val, key) { case 'maxfilesize': res.maxFileSize = val; break; + case 'timeout': + res.timeout = val; + break; case 'assetpaths': case 'assetPaths': if (_.isString(val)) { diff --git a/lib/core.js b/lib/core.js index c5269124..1ab12be0 100644 --- a/lib/core.js +++ b/lib/core.js @@ -156,6 +156,7 @@ function generate(opts) { url: file.getPenthouseUrl(opts, server.port), css: csspath, forceInclude: opts.include || [], + timeout: opts.timeout, maxEmbeddedBase64Length: opts.maxImageFileSize || 10240, // viewport width width: dimensions.width, diff --git a/test/02-generate.js b/test/02-generate.js index 9428fcdd..b0fe6a65 100644 --- a/test/02-generate.js +++ b/test/02-generate.js @@ -32,6 +32,22 @@ describe('Module - generate', function () { }, assertCritical(target, expected, done)); }); + it('should throw an error on timeout', function (done) { + var target = '.include.css'; + + critical.generate({ + base: 'fixtures/', + src: 'generate-default.html', + timeout: 1, + dest: target, + width: 1300, + height: 900 + }, function (err) { + assert.instanceOf(err, Error); + done(); + }); + }); + it('should generate critical-path CSS with query string in file name', function (done) { var expected = read('expected/generate-default.css'); var target = '.critical.css'; From 3807387081b595fc680b6eb9600ef1fb9a3c3207 Mon Sep 17 00:00:00 2001 From: leogdion Date: Thu, 16 Jun 2016 13:09:19 -0400 Subject: [PATCH 2/3] Removing .nvmrc for pull request --- .nvmrc | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index 2bf5ad04..00000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -stable From 38b521f869cb6975a527f2e5f16da8521819560d Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Thu, 23 Jun 2016 11:16:43 -0400 Subject: [PATCH 3/3] column separators should be aligned with the others --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a97591a..ed8ba750 100644 --- a/README.md +++ b/README.md @@ -222,7 +222,7 @@ critical.generate({ | inlineImages | `boolean` | `false` | Inline images | assetPaths | `array` | `[]` | List of directories/urls where the inliner should start looking for assets | maxImageFileSize | `integer` | `10240`| Sets a max file size (in bytes) for base64 inlined images -| timeout | `integer` | `30000`| Sets a maximum timeout for the operation +| timeout | `integer` | `30000`| Sets a maximum timeout for the operation | pathPrefix | `string` | `/` | Path to prepend CSS assets with. You *must* make this path absolute if you are going to be using critical in multiple target files in disparate directory depths. (eg. targeting both `/index.html` and `/admin/index.html` would require this path to start with `/` or it wouldn't work.) | include | `array` | `[]` | Force include css rules. See [`penthouse#usage`](https://github.com/pocketjoso/penthouse#usage-1). | ignore | `array` | `[]` | Ignore css rules. See [`filter-css`](https://github.com/bezoerb/filter-css) for usage examples.