A Node module to detect the path where bower components should be saved
var bowerDirectory = require('bower-directory');
bowerDirectory(function(err, result) {
if (err) {
throw err;
}
console.log('Bower directory: ' + result);
// yields: "Bower directory: /path/to/your/project/bower_components"
});
npm install --save bower-directory
var bowerDirectory = require('bower-directory');
Type: Object
Default: {}
Type: String
(relative or absolute file path)
Default: current directory
This function searches this path for .bowerrc
.
null
(by default), or a syntax error if .bowerrc
exists but isn't a valid JSON.
The absolute path where bower components should be saved. It depends on the cwd
property and directory
property of .bowerrc
. If this function cannot find .bowerrc
, it uses the default value ({"directory": "bower_components"}
).
// /path/to/your/project/foo/.bowerrc: {"cwd": "bar", "directory": "baz"}
bowerDirectory({cwd: 'foo'}, function(err, dir) {
if (err) {
throw err;
}
console.log(dir);
// yields: "/path/to/your/project/foo/bar/baz"
});
Return: String
(absolute file path)
Synchronous version of bowerDirectory()
.
You can use this module as a CLI tool by installing it globally.
npm install -g bower-direcory
bower-directory
> /path/to/current/directory/bower_components
bower-directory --help
> bower-directory:
> Detect the path where bower components should be saved
bower-directory --version
> 0.1.0
Copyright (c) 2014 Shinnosuke Watanabe
Licensed under the MIT License.