-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
177 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Electrode Archetype Option Karma | ||
|
||
Allow [Electrode](https://github.com/electrode-io/electrode) apps to optionally choose to skip installing dependencies for karma. | ||
|
||
The app can skip installing karma dependencies by adding a file `archetype/config/index.js` or `archetype/config.js` and set: | ||
|
||
```js | ||
module.exports = { | ||
options: { | ||
karma: false | ||
} | ||
}; | ||
``` | ||
|
||
If nothing is set, then default is to install. | ||
|
||
# Usage | ||
|
||
This module generally is included by other Electrode modules. An Electrode app should not need to install this directly. | ||
|
||
## Install | ||
|
||
In `package.json`: | ||
|
||
```js | ||
{ | ||
"optionalDependencies": { | ||
"electrode-archetype-opt-karma": "^1.0.0" | ||
} | ||
} | ||
``` | ||
|
||
And setup archetype config accordingly. | ||
|
||
## License | ||
|
||
Copyright (c) 2016-present, WalmartLabs | ||
|
||
Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"use strict"; | ||
|
||
const Path = require("path"); | ||
|
||
const cwd = process.env.PWD || process.cwd(); | ||
|
||
function findAppDir() { | ||
if (cwd.indexOf("node_modules") > 0) { | ||
const splits = cwd.split("node_modules"); | ||
return Path.dirname(Path.join(splits[0], "x")); // remove trailing slash | ||
} | ||
return cwd; | ||
} | ||
|
||
const appDir = findAppDir(); | ||
const myPkg = require("./package.json"); | ||
|
||
if (cwd === appDir) { | ||
try { | ||
const appPkg = require(Path.join(appDir, "package.json")); | ||
if (myPkg.name === appPkg.name) { | ||
process.exit(0); | ||
} | ||
} catch (e) {} | ||
} | ||
|
||
const name = myPkg.name; | ||
|
||
try { | ||
const config = require(Path.join(appDir, "archetype/config")); | ||
const lib = config && config.options && config.options.karma; | ||
if (lib === false) { | ||
console.log( | ||
`${name}: skipping install because archetype config set options.karma to false` | ||
); | ||
process.exit(1); | ||
} | ||
} catch (e) {} | ||
|
||
process.exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "electrode-archetype-opt-karma", | ||
"version": "1.0.0", | ||
"description": "Electrode Karma Optional Archetype", | ||
"main": "index.js", | ||
"homepage": "http://www.electrode.io", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/electrode-io/electrode.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/electrode-io/electrode/issues" | ||
}, | ||
"license": "Apache-2.0", | ||
"scripts": { | ||
"preinstall": "node optional-check.js" | ||
}, | ||
"dependencies": { | ||
"karma": "^1.7.1", | ||
"karma-chrome-launcher": "^2.1.1", | ||
"karma-coverage": "^1.1.1", | ||
"karma-firefox-launcher": "^1.0.0", | ||
"karma-ie-launcher": "^1.0.0", | ||
"karma-intl-shim": "^1.0.3", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.2", | ||
"karma-phantomjs-launcher": "^1.0.2", | ||
"karma-phantomjs-shim": "^1.4.0", | ||
"karma-safari-launcher": "^1.0.0", | ||
"karma-sonarqube-unit-reporter": "0.0.14", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-spec-reporter": "0.0.26", | ||
"karma-webpack": "^2.0.2", | ||
"phantomjs-prebuilt": "^2.1.13" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters