[
  {
    "path": ".babelrc",
    "content": "{\n  \"presets\": [\"es2015-loose\"],\n  \"plugins\": [\"transform-object-assign\"]\n}\n"
  },
  {
    "path": ".editorconfig",
    "content": "# http://editorconfig.org\nroot = true\n\n[*]\nindent_style = space\nindent_size = 2\nend_of_line = lf\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newline = true\n"
  },
  {
    "path": ".gitignore",
    "content": "# Logs\nlogs\n*.log\n\n# Runtime data\npids\n*.pid\n*.seed\n\n# Directory for instrumented libs generated by jscoverage/JSCover\nlib-cov\n\n# Coverage directory used by tools like istanbul\ncoverage\n\n# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n# node-waf configuration\n.lock-wscript\n\n# Compiled binary addons (http://nodejs.org/api/addons.html)\nbuild/Release\n\n# Dependency directory\n# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git\nnode_modules\n"
  },
  {
    "path": ".nvmrc",
    "content": "v5\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: node_js\nnode_js: 5\ninstall: npm install\nscript:\n - npm test\nbefore_cache: npm prune\nbranches:\n  only:\n    - master\n# force container based infra\n# http://docs.travis-ci.com/user/workers/container-based-infrastructure/#Routing-your-build-to-container-based-infrastructure\nsudo: false\ncache:\n  directories:\n    - node_modules\n"
  },
  {
    "path": "CHANGLELOG.md",
    "content": "See the [Releases](https://github.com/bkonkle/ignore-styles/releases) page.\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Brainspace Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# ignore-styles\n\n[![Version][version-svg]][package-url] [![Build Status][travis-svg]][travis-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![Standard][standard-svg]][standard-url]\n\nA `babel/register` style hook to ignore style imports when running in Node. This\nis for projects that use something like Webpack to enable CSS imports in\nJavaScript. When you try to run the project in Node (to test in Mocha, for\nexample) you'll see errors like this:\n\n    SyntaxError: /Users/brandon/code/my-project/src/components/my-component/style.sass: Unexpected token (1:0)\n    > 1 | .title\n    | ^\n    2 |   font-family: serif\n    3 |   font-size: 10em\n    4 |\n\nTo resolve this, require `ignore-styles` with your mocha tests:\n\n    mocha --require ignore-styles\n\nSee [DEFAULT_EXTENSIONS][default-extensions] for the full list of extensions\nignored, and send a pull request if you need more.\n\n**Note:** This is not for use *inside* Webpack. If you want to ignore extensions in Webpack you'll want to use a loader like [ignore-loader]. This is for use in Node outside of your normal Webpack build.\n\n## Installation\n\n    $ npm install --save-dev ignore-styles\n\n## More Examples\n\nTo use this with multiple Mocha requires:\n\n    mocha --require babel-register --require ignore-styles\n\nYou can also use it just like `babel/register`:\n\n```js\nimport 'ignore-styles'\n```\n\nIn ES5:\n\n```js\nrequire('ignore-styles')\n```\n\nTo customize the extensions used:\n\n```js\nimport register from 'ignore-styles'\nregister(['.sass', '.scss'])\n```\n\nTo customize the extensions in ES5:\n\n```js\nrequire('ignore-styles').default(['.sass', '.scss']);\n```\n\n## Custom handler\n\nBy default, a no-op handler is used that doesn't actually do anything. If you'd\nlike to substitute your own custom handler to do fancy things, pass it as a\nsecond argument:\n\n```js\nimport register from 'ignore-styles'\nregister(undefined, (module, filename) => {\n  module.exports = {styleName: 'fake_class_name'}\n})\n```\n\nThe first argument to `register` is the list of extensions to handle. Leaving it\nundefined, as above, uses the default list. The handler function receives two arguments, `module` and `filename`, directly\nfrom Node.\n\nWhy is this useful? One example is when using something like\n[react-css-modules][react-css-modules]. You need the style imports to actually\nreturn something so that you can test the components, or the wrapper component\nwill throw an error. Use this to provide test class names.\n\nAnother use case would be to simply return the filename of an image so that it\ncan be verified in unit tests:\n\n```js\nconst _ = require('lodash')\nconst path = require('path')\n\nregister(undefined, (module, filename) => {\n  if (_.some(['.png', '.jpg'], ext => filename.endsWith(ext))) {\n    module.exports = path.basename(filename)\n  }\n})\n```\n\nIf the filename ends in '.png' or '.jpg', then the basename of the file is\nreturned as the value of the module on import.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Brainspace Corporation\n\n[travis-svg]: https://img.shields.io/travis/bkonkle/ignore-styles/master.svg?style=flat-square\n[travis-url]: https://travis-ci.org/bkonkle/ignore-styles\n[license-image]: http://img.shields.io/badge/license-MIT-green.svg?style=flat-square\n[license-url]: LICENSE\n[downloads-image]: https://img.shields.io/npm/dm/ignore-styles.svg?style=flat-square\n[downloads-url]: http://npm-stat.com/charts.html?package=ignore-styles\n[version-svg]: https://img.shields.io/npm/v/ignore-styles.svg?style=flat-square\n[package-url]: https://npmjs.org/package/ignore-styles\n[standard-svg]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[standard-url]: http://standardjs.com/\n[default-extensions]: https://github.com/bkonkle/ignore-styles/blob/master/ignore-styles.js#L1\n[react-css-modules]: https://github.com/gajus/react-css-modules\n[ignore-loader]: https://www.npmjs.com/package/ignore-loader\n"
  },
  {
    "path": "ignore-styles.d.ts",
    "content": "/// <reference types='node' />\n\ndeclare module 'ignore-styles' {\n  type Handler = (m: NodeModule, filename: string) => any\n\n  export const DEFAULT_EXTENSIONS: string[]\n\n  export let oldHandlers: {\n    [ext: string]: Handler\n  }\n\n  export function noOp(): void\n\n  export function restore(): void\n\n  export default function register(\n    extensions?: string[],\n    handler?: Handler\n  ): void\n}\n\n"
  },
  {
    "path": "ignore-styles.js",
    "content": "export const DEFAULT_EXTENSIONS = [\n  '.css',\n  '.scss',\n  '.sass',\n  '.pcss',\n  '.stylus',\n  '.styl',\n  '.less',\n  '.sss',\n  '.gif',\n  '.jpeg',\n  '.jpg',\n  '.png',\n  '.svg',\n  '.mp4',\n  '.webm',\n  '.ogv',\n  '.aac',\n  '.mp3',\n  '.wav',\n  '.ogg'\n]\n\nexport let oldHandlers = {}\n\nexport function noOp () {}\n\nexport function restore () {\n  for (const ext in oldHandlers) {\n    if (oldHandlers[ext] === undefined) {\n      delete require.extensions[ext]\n    } else {\n      require.extensions[ext] = oldHandlers[ext]\n    }\n  }\n\n  oldHandlers = {}\n}\n\nexport default function register (extensions = DEFAULT_EXTENSIONS, handler = noOp) {\n  restore()\n\n  for (const ext of extensions) {\n    oldHandlers[ext] = require.extensions[ext]\n    require.extensions[ext] = handler\n  }\n}\n\n// Run at import\nregister()\n"
  },
  {
    "path": "lib/ignore-styles.js",
    "content": "'use strict';\n\nexports.__esModule = true;\nexports.noOp = noOp;\nexports.restore = restore;\nexports.default = register;\nvar DEFAULT_EXTENSIONS = exports.DEFAULT_EXTENSIONS = ['.css', '.scss', '.sass', '.pcss', '.stylus', '.styl', '.less', '.sss', '.gif', '.jpeg', '.jpg', '.png', '.svg', '.mp4', '.webm', '.ogv'];\n\nvar oldHandlers = exports.oldHandlers = {};\n\nfunction noOp() {}\n\nfunction restore() {\n  for (var ext in oldHandlers) {\n    if (oldHandlers[ext] === undefined) {\n      delete require.extensions[ext];\n    } else {\n      require.extensions[ext] = oldHandlers[ext];\n    }\n  }\n\n  exports.oldHandlers = oldHandlers = {};\n}\n\nfunction register() {\n  var extensions = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT_EXTENSIONS : arguments[0];\n  var handler = arguments.length <= 1 || arguments[1] === undefined ? noOp : arguments[1];\n\n  restore();\n\n  for (var _iterator = extensions, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {\n    var _ref;\n\n    if (_isArray) {\n      if (_i >= _iterator.length) break;\n      _ref = _iterator[_i++];\n    } else {\n      _i = _iterator.next();\n      if (_i.done) break;\n      _ref = _i.value;\n    }\n\n    var ext = _ref;\n\n    oldHandlers[ext] = require.extensions[ext];\n    require.extensions[ext] = handler;\n  }\n}\n\n// Run at import\nregister();\n\n//# sourceMappingURL=ignore-styles.js.map"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"ignore-styles\",\n  \"version\": \"5.0.1\",\n  \"description\": \"Ignore imported style files when running in Node\",\n  \"main\": \"lib/ignore-styles.js\",\n  \"types\": \"ignore-styles.d.js\",\n  \"scripts\": {\n    \"test\": \"standard ignore-styles.js && mocha --require babel-register\",\n    \"build\": \"babel ignore-styles.js -s -o lib/ignore-styles.js\",\n    \"watch\": \"babel ignore-styles.js -s -o lib/ignore-styles.js -w\",\n    \"prepublish\": \"npm run build\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/bkonkle/ignore-styles.git\"\n  },\n  \"author\": \"Brandon Konkle <brandon@konkle.us>\",\n  \"license\": \"MIT\",\n  \"keywords\": [\n    \"webpack\",\n    \"css\",\n    \"testing\"\n  ],\n  \"devDependencies\": {\n    \"babel-cli\": \"^6.3.17\",\n    \"babel-plugin-transform-object-assign\": \"^6.3.13\",\n    \"babel-preset-es2015-loose\": \"^6.1.3\",\n    \"babel-preset-react\": \"^6.3.13\",\n    \"babel-register\": \"^6.3.13\",\n    \"chai\": \"^3.4.1\",\n    \"mocha\": \"^2.3.3\",\n    \"standard\": \"^7.1.2\"\n  }\n}\n"
  },
  {
    "path": "test/test-ignore-styles.js",
    "content": "/* global describe, it, afterEach */\nimport { expect } from 'chai'\nimport register, * as ignoreStyles from '../ignore-styles'\n\ndescribe('ignore-styles', () => {\n  afterEach(() => {\n    ignoreStyles.oldHandlers = {}\n  })\n\n  describe('register()', () => {\n    afterEach(() => {\n      delete require.extensions['.blargh']\n    })\n\n    it('adds a no-op function as the handler for the given extensions', () => {\n      register(['.blargh'])\n      expect(require.extensions['.blargh']).to.equal(ignoreStyles.noOp)\n    })\n\n    it('saves the old handler so that it can be restored later', () => {\n      register(['.blargh'])\n      expect(ignoreStyles.oldHandlers).to.have.property('.blargh', undefined)\n    })\n\n    it('allows for a custom function to be provided instead of the no-op', () => {\n      const customHandler = () => ({soup: 'No soup for you!'})\n      register(['.blargh'], customHandler)\n      expect(require.extensions['.blargh']).to.equal(customHandler)\n    })\n  })\n\n  describe('restore', () => {\n    afterEach(() => {\n      delete require.extensions['.fake']\n    })\n\n    it('returns the handlers back to their previous state', () => {\n      function fakeHandler () {}\n      require.extensions['.fake'] = fakeHandler\n\n      register(['.fake'])\n      expect(require.extensions['.fake']).to.equal(ignoreStyles.noOp)\n\n      ignoreStyles.restore()\n      expect(require.extensions['.fake']).to.equal(fakeHandler)\n    })\n  })\n})\n"
  }
]