[
  {
    "path": ".gitignore",
    "content": "# Logs\nlogs\n*.log\nnpm-debug.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.nyc_output\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\nnode_modules\n\n# Optional npm cache directory\n.npm\n\n# Optional REPL history\n.node_repl_history\n\n# mac files\n.DS_Store\n\n# vim swap files\n*.swp\n\n# locks\npackage-lock.json\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: node_js\n\nenv:\n  - NODE=6\n\nos:\n  - linux\n  - osx\n\naddons:\n  apt:\n    packages:\n      - xvfb\n\ninstall:\n  - rm -rf ~/.nvm\n  - git clone https://github.com/creationix/nvm.git ~/.nvm\n  - source ~/.nvm/nvm.sh\n  - nvm install $NODE\n  - nvm --version\n  - node --version\n  - npm --version\n  - npm install\n\nscript:\n  - npm test\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2016 Tomas Della Vedova\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": "# electron-is\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://travis-ci.org/delvedor/electron-is.svg?branch=master)](https://travis-ci.org/delvedor/electron-is)\n\nAn 'is' utility for Electron.  \n`electron-is` provides a set of isomorphic 'is' APIs, that you can use it both in main and renderer process.  \nSee <a href=\"#usage\">usage</a> for more information.\n\n## Install\n```\n$ npm install electron-is --save\n```\n\n## API\n\n- **is.renderer()**  \nReturns `true` if you are calling the function from the renderer process.\n\n- **is.main()**  \nReturns `true` if you are calling the function from the main process.\n\n- **is.macOS()** *aliases* **is.osx()**  \nReturns `true` if your app is running under Mac OS.\n\n- **is.windows()**  \nReturns `true` if your app is running under Windows OS.\n\n- **is.linux()**  \nReturns `true` if your app is running under Linux OS.\n\n- **is.x86()**  \nReturns `true` if you the architecture of the processor is `ia32`.\n\n- **is.x64()**  \nReturns `true` if you the architecture of the processor is `x64`.\n\n- **is.production()**  \nReturns `true` if you are running the app in a `production` environment.\n\n- **is.dev()**  \nReturns `true` if you are running the app in a `dev` environment.\n\n- **is.sandbox()** *only* ***macOS***  \nReturns `true` if you are running the app in a `sandbox` environment under macOS.\n\n- **is.mas()**  \nReturns `true` if the app is running as a Mac App Store build.\n\n- **is.windowsStore()**  \nReturns `true` if the app is running as a Windows Store (appx) build.\n\n- **is.all(args)**  \nReturns `true` if all the 'is functions' passed as argument are true.  \nexample: `is.all(is.osx, is.x64)`\n\n- **is.none(args)**  \nReturns `true` if all the 'is functions' passed as argument are false.  \nexample: `is.none(is.windows, is.x86, is.main)`\n\n- **is.one(args)**  \nReturns `true` if one of the 'is functions' passed as argument is true.  \nexample: `is.one(is.osx, is.linux)`\n\n- **is.release(args)**  \nChecks the if the given release is the same of the OS (\\*)  \nexample: `is.release('10.0.10586')`\n\n- **is.gtRelease(args)**  \nChecks if the given release is greater than the current OS release (\\*)  \nexample: `is.gtRelease('10.9.5')`\n\n- **is.ltRelease(args)**  \nChecks if the given release is less than the current OS release (\\*)  \nexample: `is.ltRelease('6.3')`\n\nThe [Mac](https://en.wikipedia.org/wiki/Darwin_%28operating_system%29#Release_history) versions are mapped as `osx: darwin`, you must pass the *9.x.y* or *10.x.y* OSX version as argument and not the darwin version.  \nIf you are testing a [Windows](https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions) release you must pass the NT release, it can be *x.y* or *x.y.build* .\n\n\\* *Not implemented for Linux yet*\n\n<a name=\"usage\"></a>\n## Usage\n- In Main process:\n```javascript\n// es6\nimport is from 'electron-is'\n// es5\nconst is = require('electron-is')\nconsole.log(is.main())\n```\n- In Renderer process:\n```html\n<script>\n    const is = require('electron-is')\n    console.log(is.renderer())\n</script>\n```\n## Acknowledgements\n`electron-is` makes use of [electron-is-dev](https://github.com/sindresorhus/electron-is-dev) package from [@sindresorhus](https://github.com/sindresorhus).\n\n## Contributing\nIf you feel you can help in any way, be it with examples, extra testing, or new features please open a pull request or open an issue.\n\nThe code follows the Standard code style.  \n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n______________________________________________________________________________________________________________________\n## License\n**[MIT](https://github.com/delvedor/electron-is/blob/master/LICENSE)**\n\n*The software is provided \"as is\", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non infringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.*\n\nCopyright © 2016 Tomas Della Vedova\n"
  },
  {
    "path": "is.d.ts",
    "content": "declare namespace is {\n  export function renderer(): boolean;\n  export function main(): boolean;\n  export function osx(): boolean;\n  export function macOS(): boolean;\n  export function windows(): boolean;\n  export function linux(): boolean;\n  export function x86(): boolean;\n  export function x64(): boolean;\n  export function production(): boolean;\n  export function dev(): boolean;\n  export function sandbox(): boolean;\n  export function mas(): boolean;\n  export function windowsStore(): boolean;\n  export function all(): boolean;\n  export function none(): boolean;\n  export function one(): boolean;\n  export function release(requested: string): boolean;\n  export function gtRelease(requested: string): boolean;\n  export function ltRelease(requested: string): boolean;\n}\ndeclare function is (): any;\nexport = is;\n"
  },
  {
    "path": "is.js",
    "content": "/*\n * Project: electron-is\n * Version: 3.0.0\n * Author: delvedor\n * Twitter: @delvedor\n * License: MIT\n * GitHub: https://github.com/delvedor/electron-is\n */\n'use strict'\n\nconst semver = require('semver')\nconst gt = semver.gt\nconst lt = semver.lt\nconst release = require('os').release\nconst isDev = require('electron-is-dev')\n\nmodule.exports = {\n  // Checks if we are in renderer process\n  renderer: function () {\n    return process.type === 'renderer'\n  },\n  // Checks if we are in main process\n  main: function () {\n    return process.type === 'browser'\n  },\n  // Checks if we are under Mac OS\n  osx: function () {\n    return process.platform === 'darwin'\n  },\n  // Checks if we are under Mac OS\n  macOS: function () {\n    return this.osx()\n  },\n  // Checks if we are under Windows OS\n  windows: function () {\n    return process.platform === 'win32'\n  },\n  // Checks if we are under Linux OS\n  linux: function () {\n    return process.platform === 'linux'\n  },\n  // Checks if we are the processor's arch is x86\n  x86: function () {\n    return process.arch === 'ia32'\n  },\n  // Checks if we are the processor's arch is x64\n  x64: function () {\n    return process.arch === 'x64'\n  },\n  // Checks if the env is setted to 'production'\n  production: function () {\n    return !isDev\n  },\n  // Checks if the env is setted to 'dev'\n  dev: function () {\n    return isDev\n  },\n  // Checks if the app is running in a sandbox on macOS\n  sandbox: function () {\n    return 'APP_SANDBOX_CONTAINER_ID' in process.env\n  },\n  // Checks if the app is running as a Mac App Store build\n  mas: function () {\n    return process.mas === true\n  },\n  // Checks if the app is running as a Windows Store (appx) build\n  windowsStore: function () {\n    return process.windowsStore === true\n  },\n  // checks if all the 'is functions' passed as arguments are true\n  all: function () {\n    const isFunctions = new Array(arguments.length)\n    for (var i = 0; i < isFunctions.length; i++) {\n      isFunctions[i] = arguments[i]\n    }\n    if (!isFunctions.length) return\n    for (i = 0; i < isFunctions.length; i++) {\n      if (!isFunctions[i]()) return false\n    }\n    return true\n  },\n  // checks if all the 'is functions' passed as arguments are false\n  none: function () {\n    const isFunctions = new Array(arguments.length)\n    for (var i = 0; i < isFunctions.length; i++) {\n      isFunctions[i] = arguments[i]\n    }\n    if (!isFunctions.length) return\n    for (i = 0; i < isFunctions.length; i++) {\n      if (isFunctions[i]()) return false\n    }\n    return true\n  },\n  // returns true if one of the 'is functions' passed as argument is true\n  one: function () {\n    const isFunctions = new Array(arguments.length)\n    for (var i = 0; i < isFunctions.length; i++) {\n      isFunctions[i] = arguments[i]\n    }\n    if (!isFunctions.length) return\n    for (i = 0; i < isFunctions.length; i++) {\n      if (isFunctions[i]()) return true\n    }\n    return false\n  },\n  // checks the if the given release is the same of the OS\n  release: function (requested) {\n    if (this.osx()) {\n      return requested === osxRelease()\n    } else if (this.windows()) {\n      requested = requested.split('.')\n      const actual = release().split('.')\n      if (requested.length === 2) {\n        return `${actual[0]}.${actual[1]}` === `${requested[0]}.${requested[1]}`\n      }\n      return `${actual[0]}.${actual[1]}.${actual[2]}` === `${requested[0]}.${requested[1]}.${requested[2]}`\n    } else {\n      // Not implemented for Linux yet\n      return null\n    }\n  },\n  // checks if the given release is greater than the current OS release\n  gtRelease: function (requested) {\n    if (this.osx()) {\n      return gt(requested, osxRelease())\n    } else if (this.windows()) {\n      requested = requested.split('.')\n      const actual = release().split('.')\n      if (requested.length === 2) {\n        return gt(`${requested[0]}.${requested[1]}.0`, `${actual[0]}.${actual[1]}.0`)\n      }\n      return gt(`${requested[0]}.${requested[1]}.${requested[2]}`, `${actual[0]}.${actual[1]}.${actual[2]}`)\n    } else {\n      // Not implemented for Linux yet\n      return null\n    }\n  },\n  // checks if the given release is less than the current OS release\n  ltRelease: function (requested) {\n    if (this.osx()) {\n      return lt(requested, osxRelease())\n    } else if (this.windows()) {\n      requested = requested.split('.')\n      const actual = release().split('.')\n      if (requested.length === 2) {\n        return lt(`${requested[0]}.${requested[1]}.0`, `${actual[0]}.${actual[1]}.0`)\n      }\n      return lt(`${requested[0]}.${requested[1]}.${requested[2]}`, `${actual[0]}.${actual[1]}.${actual[2]}`)\n    } else {\n      // Not implemented for Linux yet\n      return null\n    }\n  }\n}\n\n// returns the current osx release\nfunction osxRelease () {\n  const actual = release().split('.')\n  return `10.${actual[0] - 4}.${actual[1]}`\n}\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"electron-is\",\n  \"version\": \"3.0.0\",\n  \"description\": \"An 'is' utility for Electron which provides a set of handy functions, with a self-descriptive name.\",\n  \"main\": \"is.js\",\n  \"scripts\": {\n    \"pretest\": \"standard\",\n    \"test\": \"node test/headless-test.js\"\n  },\n  \"keywords\": [\n    \"platform\",\n    \"type\",\n    \"process\",\n    \"arch\",\n    \"env\",\n    \"electron\",\n    \"os\",\n    \"release\",\n    \"is\",\n    \"main\",\n    \"renderer\"\n  ],\n  \"author\": \"Tomas Della Vedova - @delvedor (http://delved.org)\",\n  \"contributors\": [\n    \"Masoud Ghorbani <msud.ghorbani@gmail.com> (http://msud.ir)\"\n  ],\n  \"license\": \"MIT\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/delvedor/electron-is.git\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/delvedor/electron-is/issues\"\n  },\n  \"homepage\": \"https://github.com/delvedor/electron-is#readme\",\n  \"devDependencies\": {\n    \"electron-eval\": \"^0.9.10\",\n    \"standard\": \"^11.0.1\"\n  },\n  \"dependencies\": {\n    \"electron-is-dev\": \"^0.3.0\",\n    \"semver\": \"^5.5.0\"\n  }\n}\n"
  },
  {
    "path": "test/assertions.js",
    "content": "'use strict'\n\nconst assert = require('assert')\nconst release = require('os').release\nconst path = require('path')\nconst is = require(path.join(__dirname, '..', '..', '..', 'is'))\n\nfunction assertions () {\n  assert.equal(is.main(), process.type === 'browser', 'is.main() not ok!')\n  assert.equal(is.renderer(), process.type === 'renderer', 'is.renderer() not ok!')\n\n  assert.equal(is.osx(), process.platform === 'darwin', 'is.osx() not ok!')\n  assert.equal(is.macOS(), process.platform === 'darwin', 'is.macOS() not ok!')\n  assert.equal(is.windows(), process.platform === 'win32', 'is.windows() not ok!')\n  assert.equal(is.linux(), process.platform === 'linux', 'is.linux() not ok!')\n\n  assert.equal(is.x86(), process.arch === 'ia32', 'is.x86() not ok!')\n  assert.equal(is.x64(), process.arch === 'x64', 'is.x64() not ok!')\n\n  assert.equal(is.production(), (process.env.NODE_ENV || 'dev') === 'production', 'is.production() not ok!')\n  assert.equal(is.dev(), (process.env.NODE_ENV || 'dev') === 'dev', 'is.dev() not ok!')\n\n  assert.equal(is.sandbox(), ('APP_SANDBOX_CONTAINER_ID' in process.env), 'is.sandbox() not ok!')\n  assert.equal(is.mas(), process.mas === true, 'is.mas() not ok!')\n  assert.equal(is.windowsStore(), process.windowsStore === true, 'is.windowsStore() not ok!')\n\n  assert.equal(is.all(is.osx, is.x64), is.osx() && is.x64(), 'is.all() 1 not ok!')\n  assert.equal(is.all(is.osx, is.x86), is.osx() && is.x86(), 'is.all() 2 not ok!')\n  assert.equal(is.none(is.windows, is.x86), !is.windows() && !is.x86(), 'is.none() 1 not ok!')\n  assert.equal(is.none(is.windows, is.x64), !is.windows() && !is.x64(), 'is.none() 2 not ok!')\n  assert.equal(is.one(is.windows, is.osx), is.windows() || is.osx(), 'is.one() 1 not ok!')\n  assert.equal(is.one(is.windows, is.linux), is.windows() || is.linux(), 'is.one() 2 not ok!')\n\n  if (is.osx()) {\n    const osx = osxRelease()\n    // mac el capitan\n    assert.equal(is.release(osx), true, 'is.release() not ok!')\n\n    assert.equal(is.gtRelease(osx), false, 'is.gtRelease() 1 not ok!')\n    assert.equal(is.gtRelease('100.100.100'), true, 'is.gtRelease() 2 not ok!')\n    assert.equal(is.gtRelease('1.0.0'), false, 'is.gtRelease() 3 not ok!')\n\n    assert.equal(is.ltRelease(osx), false, 'is.ltRelease() 1 not ok!')\n    assert.equal(is.ltRelease('100.100.100'), false, 'is.ltRelease() 2 not ok!')\n    assert.equal(is.ltRelease('1.0.0'), true, 'is.ltRelease() 3 not ok!')\n  } else if (is.windows()) {\n    // tests Windows 10 AU\n    assert.equal(is.release('10.0'), true, 'is.release() not ok!')\n    assert.equal(is.release('10.0.14393'), true, 'is.release() not ok!')\n  } else {\n    assert.equal(is.release('1.2.3'), null, 'is.release() not ok!')\n  }\n\n  return true\n}\n\n// returns the current osx release\nfunction osxRelease () {\n  const actual = release().split('.')\n  return `10.${actual[0] - 4}.${actual[1]}`\n}\n\nassertions()\n"
  },
  {
    "path": "test/headless-test.js",
    "content": "'use strict'\n\nconst fs = require('fs')\nconst electronEval = require('electron-eval')\n\nconst assertions = fs.readFileSync('./test/assertions.js', 'utf8')\nconst daemon = electronEval()\n\n;(function test (options) {\n  daemon.eval(assertions, { mainProcess: options.main }, (err, res) => {\n    if (err) {\n      console.log(err.message)\n      process.exit(1)\n    }\n    if (options.main) {\n      test({ main: false })\n    } else {\n      daemon.close()\n      console.log('All test passed!')\n      process.exit(0)\n    }\n  })\n})({ main: true })\n"
  }
]