Giter Site home page Giter Site logo

wmaker's Introduction

wMaker Build Status

Analog of so-called 'make' in Java Script.

Installation

npm install wmaker

Usage

Options

Name Type Optional Description
opt object * Structure for storing user defined variables.
recipe array - Array which stores make recipes.
defaultTargetName string * Make will run this target by default, useful with multiple recipes, if not specified first target in the structure will be default.
usingLogging bool * Enable logging of making process, enabled by default.
currentPath string * Current working directory, by default is the folder where make script is located.

Target

Property Type Description
name string Target name.
shell string Commands to execute in comand prompt.
after array/string Files for validation and "up-to-date" check with files from 'before'. Validation - check whether all files from this list exists. "Up-to-date" means that any file from 'after' property is newer then other any file from 'before' or they have same date.
before array/string Dependencies( files/targets ) that must checked for "up-to-date" before recipe execution.If recipe is "up-to-date" it will not be executed.
pre function Function called at the beginning of recipe execution.
post function Function called at the ending of recipe execution.

Methods

Name Description
form Runs default target using name specified as 'defaultTargetName'.
exec Runs default target using name specified as 'defaultTargetName' or as command line argument.
makeTarget Runs target using name passed as argument.
Example #1
/*simplest make target example using g++*/
var target =
{
  after : 'my_file.o',
  before : 'my_file.cpp',
  shell : `g++ -c my_file.cpp -o my_file.o`
}
wMaker({ recipe : [ target ] }).form();
Example #2
/*example of using pre function in target*/
var _ = wTools;
var pre = function()
{ /*some useful code here for example creating *.cpp file */
  var code = 'int  main() { return 0; }';
  fileProvider = _.FileProvider.HardDrive();
  fileProvider.fileWriteAct
  ({
      filePath : 'my_file.cpp',
      data : code,
      sync : 1,
  });
}

var target =
{
  pre : pre,
  after : 'my_file.o',
  before : 'my_file.cpp',
  shell : `g++ -c my_file.cpp -o my_file.o`
}
wMaker({ recipe : [ target ] }).form();
Example #3
/*run specific target using makeTarget*/
var target =
{
  name : 't1',
  after : 'my_file.o',
  before : 'my_file.cpp',
  shell : `g++ -c my_file.cpp -o my_file.o`
}
var maker = wMaker
({
  recipe : [ target ],
  defaultTargetName : '' /*disable default target execution by form()*/
});
maker.form(); /*run form to process provided target info*/
maker.makeTarget( 't1' ); /*run recipe t1*/
Example #4
/*run specific target using command line*/
var target =
[
  {
    name : 't1',
    after : 'my_file.o',
    before : 'my_file.cpp',
    shell : `g++ -c my_file.cpp -o my_file.o`
  },
  {
    name : 't2',
    after : 'my_file', /*on windows: my_file.exe*/
    before : 'my_file.o',
    shell : `g++ my_file.o -o my_file`
  }
]
wMaker({ recipe : target }).exec();
node my_make_file.js t1

wmaker's People

Contributors

wandalen avatar vmihdal avatar dmvict avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.