Skip to content
lucentminds edited this page Jun 8, 2017 · 2 revisions

Here's what's inside of bob.

bob.createJob( cJobname[,fnFirsttask] )

Creates a new job to add a list of tasks to.

var concat = require( 'promise-file-concat' );
var buildJob = createJob( 'build-main' );

buildJob.addTask( 'concat', function(){
   var aFiles = [
      './file1.js',
      './file2.js',
      './file3.js'
   ];

   // Concatenate this list of files together.
   return concat( aFiles, './temp/concatenated.js' );
} );

buildJob.run()
.then(function(){
   console.log( 'Done!' );
})

bob.cwd( cDirpath )

Sets the working directory of the current environment. Most useful when dealing with sub-bobs.

bob.cwd( __dirname );
// or
bob.cwd( '/home/user/project' );

bob.getData( [cProp] )

Fetches an arbitrary value that was set by bob.setData. If no arguments are passed to the method, it returns the entire data object stored in the bob. Most useful when dealing with sub-bobs.

var time = bob.getData( 'time' );
// or
var object = bob.getData();

bob.getJob( cJobname )

Fetches a specific job from the list of jobs that are registered in bob.

bob.getJob( 'build' ).run();
// or
bob.getJob( 'build-modules' ).run()
.then(function(){
   return bob.getJob( 'build-main' ).run();
})

bob.log( cLevel, ...args )

Outputs formatted text to console. Similar to native console logging, but with log level tracking.

bob.log( 'info', 'Hello,', 'world.' );
// or
bob.log( 'error', 'Oops!' );

bob.resolve( cFilepath )

Resolves a path ( typically relative ) based on the value set by bob.cwd. Most useful when dealing with sub-bobs.

bob.cwd( __dirname );
console.log( bob.resolve( './test.txt' ) );

bob.setData( cProp, value )

bob.setData( { prop:value, prop:value, ...props } )

Sets arbitrary data that can be used later by other bobs and jobs. Data can be fetched by bob.getData. Most useful when dealing with sub-bobs.

bob.setData( 'time', new Date() );
// or
bob.setData({
   time: new Date(),
   watchlist: [
      '/path/to/watch1',
      '/path/to/watch2',
      '/path/to/watch3'
   ]
});

bob.watch( cPath )

bob.watch( [ cPath, cPath, cPath ] )

Watches one or more file paths for changes. Use bob.on( 'change', function(){} ) to perform actions when a change occurs. Returns a promise that is resolved once all of the paths are being watched.

bob.on( 'change', function( bob, path ){
   console.log( 'changed:', path );
});

bob.watch( [ './src', './static' ] )

.then(function( bob ){
   console.log( 'Watching!' );
});