node package manager

bower-directory

bower-directory

Build Status Build status Coverage Status Dependency Status devDependency Status

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" 
}); 

Installation

NPM version

Use npm.

npm install --save bower-directory

API

var bowerDirectory = require('bower-directory');

bowerDirectory([option, ]callback)

option

Type: Object
Default: {}

option.cwd

Type: String (relative or absolute file path)
Default: current directory

This function searches this path for .bowerrc.

callback(error, path)

error

null (by default), or a syntax error if .bowerrc exists but isn't a valid JSON.

path

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" 
});

bowerDirectory.sync(option)

Return: String (absolute file path)

Synchronous version of bowerDirectory().

CLI

You can use this module as a CLI tool by installing it globally.

npm install -g bower-direcory

Usage

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

License

Copyright (c) 2014 Shinnosuke Watanabe

Licensed under the MIT License.