Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tengattack committed Nov 21, 2016
0 parents commit 63a3af7
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [ "es2017-node7" ]
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
npm-debug.log

.DS_Store
40 changes: 40 additions & 0 deletions lib/index.js
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;

35 changes: 35 additions & 0 deletions package.json
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"
}
}
26 changes: 26 additions & 0 deletions src/index.es
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

0 comments on commit 63a3af7

Please sign in to comment.