Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from aaharu/basepath
Browse files Browse the repository at this point in the history
Basepath
  • Loading branch information
aaharu authored Jan 2, 2017
2 parents 17c1fef + 89a7904 commit f0e3867
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 39 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[*.{yml,yaml,json}]
indent_size = 2

[.eslintrc]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
10 changes: 5 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"env": {
"node": true,
"mocha": true
},
"extends": "eslint:recommended"
"env": {
"node": true,
"mocha": true
},
"extends": "eslint:recommended"
}
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
*.* text eol=lf
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
language: node_js
node_js:
- "0.10"
- "0.12"
- "4.1"
- "4"
- "6"
after_success: "npm run coverage"

branches:
only: [ master ]

notifications:
email: false
4 changes: 0 additions & 4 deletions CHANGELOG

This file was deleted.

14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Change Log

## [0.2.0] - 2017-01-02
### Fixed
- fix !!inc relative path problem.

### Changed
- update dependencies packages.

## [0.1.1] - 2015-10-25
### Changed
- update dependencies packages.

## [0.1.0] - 2015-08-11
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ gulp.task("sample", function () {
`src/base.yaml`
```yaml
version: 1
# known issue: relative path problem
sub: !!inc/file src/parts/sub.yaml
sub: !!inc/file parts/sub.yaml
```
`src/parts/sub.yaml`
Expand All @@ -50,10 +49,6 @@ sub:
hoge: fuga
```

## TODO

- fix relative paths

## LICENSE

BSD-2-Clause
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-yaml-include",
"version": "0.1.1",
"version": "0.2.0",
"description": "A gulp plugin for yaml-include.",
"main": "./src/index.js",
"scripts": {
Expand All @@ -14,17 +14,18 @@
"author": "aaharu",
"license": "BSD-2-Clause",
"dependencies": {
"js-yaml": "^3.4.2",
"through2": "^2.0.0",
"yaml-include": "^1.1.0"
"js-yaml": "^3.7.0",
"through2": "^2.0.3",
"yaml-include": "^1.2.0"
},
"devDependencies": {
"gulp-util": "^3.0.6",
"coveralls": "^2.11.4",
"event-stream": "^3.3.1",
"istanbul": "^0.4.0",
"mocha": "^2.3.3",
"mocha-lcov-reporter": "^1.0.0"
"coveralls": "^2.11.15",
"eslint": "^3.12.2",
"event-stream": "^3.3.4",
"gulp-util": "^3.0.8",
"istanbul": "^0.4.5",
"mocha": "^2.5.3",
"mocha-lcov-reporter": "^1.2.0"
},
"keywords": [
"yaml",
Expand Down
5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ var through = require("through2"),
yamlinc = require("yaml-include"),
PassThrough = require("stream").PassThrough;

module.exports = function (opt) {

opt = opt || {}; //TODO
module.exports = function () {

return through.obj(function (file, enc, cb) {
if (file.isNull()) {
// return empty file
return cb(null, file);
}
yamlinc.setBaseFile(file.path);
if (file.isBuffer()) {
var yml = yaml.load(file.contents.toString(enc), {
schema: yamlinc.YAML_INCLUDE_SCHEMA,
Expand Down
2 changes: 2 additions & 0 deletions tests/base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version: 1
sub: !!inc/file subdir/sub.yaml
1 change: 1 addition & 0 deletions tests/subdir/sub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hoge: fuga
41 changes: 33 additions & 8 deletions tests/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

"use strict";

var assert = require("assert"),
var path = require("path"),
fs = require("fs"),
assert = require("assert"),
es = require("event-stream"),
gutil = require("gulp-util"),
PassThrough = require("stream").PassThrough,
Expand All @@ -10,9 +11,11 @@ var assert = require("assert"),
describe("gulp-yaml-include", function () {
it("should work in buffer mode", function (done) {
var stream = index();
var testBuffer = new Buffer("paths: !!inc/file tests/hoge.yaml"),
testFile = new gutil.File({
contents: testBuffer
var testFile = new gutil.File({
base: __dirname,
cwd: __dirname,
path: path.join(__dirname, 'test.yaml'),
contents: fs.readFileSync(path.join(__dirname, "test.yaml"))
});

stream.on("data", function () {
Expand All @@ -31,11 +34,12 @@ describe("gulp-yaml-include", function () {
var stream = index();
var testStream = new PassThrough();
var testFile = new gutil.File({
base: __dirname,
cwd: __dirname,
path: path.join(__dirname, 'test.yaml'),
contents: testStream
});
testStream.write(new Buffer("paths: !!inc/file tests/hoge.yaml"));
testStream.write(new Buffer("\n"));
testStream.write(new Buffer("c: 1"));
testStream.write(fs.readFileSync(path.join(__dirname, "test.yaml")));
testStream.end();

stream.on("data", function (newFile) {
Expand Down Expand Up @@ -69,4 +73,25 @@ describe("gulp-yaml-include", function () {
}));
stream.end();
});

it("should work subdir inc", function (done) {
var stream = index();
var testFile = new gutil.File({
base: __dirname,
cwd: __dirname,
path: path.join(__dirname, 'base.yaml'),
contents: fs.readFileSync(path.join(__dirname, "base.yaml"))
});

stream.on("data", function () {
assert.equal("version: 1\nsub:\n hoge: fuga\n", testFile.contents.toString());
});

stream.on("end", function () {
done();
});

stream.write(testFile);
stream.end();
});
});
1 change: 1 addition & 0 deletions tests/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
paths: !!inc/file hoge.yaml

0 comments on commit f0e3867

Please sign in to comment.