-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 63a3af7
Showing
5 changed files
with
108 additions
and
0 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,3 @@ | ||
{ | ||
"presets": [ "es2017-node7" ] | ||
} |
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,4 @@ | ||
node_modules | ||
npm-debug.log | ||
|
||
.DS_Store |
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'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _path = require('path'); | ||
|
||
var _path2 = _interopRequireDefault(_path); | ||
|
||
var _jsYaml = require('js-yaml'); | ||
|
||
var _jsYaml2 = _interopRequireDefault(_jsYaml); | ||
|
||
var _lodash = require('lodash'); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
const configValidFields = ['render', 'deployer']; | ||
|
||
class HaneConfig { | ||
constructor(root) { | ||
let config; | ||
try { | ||
const configPath = _path2.default.join(root, 'hane.yml'); | ||
const data = fs.readFileSync(configPath, 'utf8'); | ||
config = _jsYaml2.default.safeLoad(data); | ||
config = (0, _lodash.pick)(config, configValidFields); | ||
} catch (e) { | ||
config = {}; | ||
} | ||
this.config = config; | ||
} | ||
get render() { | ||
return this.config.render || {}; | ||
} | ||
} | ||
|
||
exports.default = HaneConfig; | ||
|
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,35 @@ | ||
{ | ||
"name": "hane-config", | ||
"version": "0.2.0", | ||
"description": "Config parser for hanejs.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "babel src/index.es > lib/index.js", | ||
"postinstall": "npm run build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/hanejs/hane-config.git" | ||
}, | ||
"keywords": [ | ||
"hane", | ||
"hanejs", | ||
"config", | ||
"parser" | ||
], | ||
"author": "tengattack", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/hanejs/hane-config/issues" | ||
}, | ||
"homepage": "https://github.com/hanejs/hane-config#readme", | ||
"devDependencies": { | ||
"babel-cli": "^6.18.0", | ||
"babel-preset-es2017-node7": "^0.4.1" | ||
}, | ||
"dependencies": { | ||
"js-yaml": "^3.7.0", | ||
"lodash": "^4.17.2" | ||
} | ||
} |
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,26 @@ | ||
|
||
import path from 'path' | ||
import yaml from 'js-yaml' | ||
import { pick } from 'lodash' | ||
|
||
const configValidFields = [ 'render', 'deployer' ] | ||
|
||
class HaneConfig { | ||
constructor(root) { | ||
let config | ||
try { | ||
const configPath = path.join(root, 'hane.yml') | ||
const data = fs.readFileSync(configPath, 'utf8') | ||
config = yaml.safeLoad(data) | ||
config = pick(config, configValidFields) | ||
} catch (e) { | ||
config = {} | ||
} | ||
this.config = config | ||
} | ||
get render() { | ||
return this.config.render || {} | ||
} | ||
} | ||
|
||
export default HaneConfig |