Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp / Bower - maintaining consistency

I feel like im missing something stupid here, can someone explain to me why i can't pull in .bowerrc into gulp? The file structure and process should be extremely simple:

File Tree

global.js

"use strict";

var gulp = require('gulp');
var bowerRC = require('../.bowerrc');

module.exports.getBowerRC = function() {
    return console.log(JSON.stringify(bowerRC));
}

.bowerrc

{
    "directory": "./resources/bower_components/",
    "analytics": false
}

Ok so what i want to do is basically pull in the value of "directory" as a global in gulp. That way gulp can automagically use the value for whatever tasks / plugins and it maintains DRY concepts without breaking the bower shell itself.

The problem is, when i call the function from a task it errors. The strange part is if i switch the variable bowerRC to point at bower.json it works fine for that... thoughts?

For reference im using node v0.12.0 , gulp v3.9.0 , bower v1.4.1

EDIT: running it on windows7 64bit, no choice im afraid

EDIT2: Updated to node 0.12.4, no change i believe it has something to do with how files are required since even if i comment out the function the error persists.

console

like image 786
marblewraith Avatar asked Jun 08 '15 10:06

marblewraith


1 Answers

Figured it out, altered code looks like this:

"use strict";

var gulp = require('gulp');
var fs = require('fs');

module.exports.getBowerRC = function ()
{
    var bowerRC = JSON.parse(fs.readFileSync('./.bowerrc', 'utf8'));
    return console.log(bowerRC);
}
like image 110
marblewraith Avatar answered Oct 19 '22 11:10

marblewraith