diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 992325c..3fe47e2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,12 +2,13 @@ name: Node.js Unit Tests on: push: + branches: + - master pull_request: jobs: build-front: runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.allow-failure || false }} strategy: matrix: @@ -30,6 +31,7 @@ jobs: - name: Install and run tests run: npm install-ci-test + continue-on-error: ${{ matrix.allow-failure || false }} - name: Run CLI commands run: | diff --git a/README.md b/README.md index 47d4450..20e8b30 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,23 @@ crx.load( path.resolve(__dirname, './myExtension') ) ``` ### ChromeExtension = require("crx") -### crx = new ChromeExtension(attrs) +### crx = new ChromeExtension(attrs?) This module exports the `ChromeExtension` constructor directly, which can take an optional attribute object, which is used to extend the instance. +`attrs` is an optional object with advanced configuration elements: + +```js +crx = new ChromeExtension({ + // By default, we exclude bundling crx extensions within extensions + // You can change that, and ignore other files as well + ignore: ['*.crx'] + // By default, it produces extensions compatible with CRX version 3 (since Chromium 64) + // CRX version 2 is for Chromium versions prior to 64 + version: 3 +}) +``` + ### crx.load(path|files) Prepares the temporary workspace for the Chrome Extension located at `path` — which is expected to directly contain `manifest.json`. diff --git a/src/index.js b/src/index.js index b312c46..f8ad9a5 100644 --- a/src/index.js +++ b/src/index.js @@ -17,6 +17,7 @@ const DEFAULTS = { codebase: null, path: null, src: "**", + ignore: ["*.crx"], version: 3, }; @@ -157,7 +158,7 @@ class ChromeExtension { .glob(selfie.src, { cwd: selfie.path, matchBase: true, - ignore: ["*.pem", ".git", "*.crx"] + ignore: ["*.pem", ".git"].concat(selfie.ignore) }) .finalize(); }); diff --git a/test/index.js b/test/index.js index 1d7733b..880cee6 100644 --- a/test/index.js +++ b/test/index.js @@ -86,6 +86,28 @@ TESTS.writeFile = function(t, opts){ t.throws(() => crx.writeFile('/tmp/crx')); }; +TESTS.ignoreFiles = function(t, opts){ + t.plan(1); + + var crx = newCrx(Object.assign({ + ignore: ['*.png'] + }, opts)); + + crx.load().then(function(){ + return crx.loadContents(); + }) + .then(function(packageData){ + var entries = new Zip(packageData) + .getEntries() + .map(function(entry){ + return entry.entryName; + }) + + t.deepEqual(entries, ['manifest.json']); + }) + .catch(t.error.bind(t)); +}; + TESTS.loadContents = function(t, opts){ t.plan(3); @@ -127,7 +149,7 @@ TESTS.generateUpdateXML = function(t, opts){ t.throws(() => new ChromeExtension({}).generateUpdateXML(), 'No URL provided for update.xml'); var crx = newCrx(opts); - var expected = crx.version === 2 ? updateXml2 : updateXml3; + var expected = crx.version === 2 ? updateXml2 : updateXml3; crx.pack().then(function(){ var xmlBuffer = crx.generateUpdateXML();