Skip to content

fbeuster/js-build

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JS Build

BSD-2-Clause License

This is a small shell script, that allows you to import JavaScript files into other ones. I made it during an IBM 10% Hackday at work and it's probably very limited but works for my use.

Any suggestions for improvements are appreciated.

Installation

To install JS Build, simply clone the repository and run the following command the ´install´ script in the Git directory.

git clone https://github.com/fbeuster/js-build.git
./install

The script will ask you for root access to install dependencies and copy the program files into the ´/usr/local/bin´ directory.

Dependencies

Usage

Import in JavaScript

Right now you can only import JavaScript files into a main file. The way you do this in your JavaScript code is

//@ imported_code
//@ sub_folder/more_code
console.log('hello world')

In the case above you have the following folder structure

|
+- my_source.js
+- imported_code.js
+- sub_folder
   |
   +- more_code.js

Every line of //@ some_name is interpreted as a single JavaScript file you want to import.

Build the Code

To run the build once and merge the main and import files, just do

$ ./js-build my_source.js

The file is written in the same directory the original main file is placed and will have an _compiled in its file name.

Note: You can also set your own output file. Read more in a later section.

Using the file system listener

If you want to start the change listener (requires inotify-tools to work):

$ ./js-build-watch my_source.js

This listens to any file changes in all subdirectories of your main javaScript file.

Setting a custom output file

If you don't want a pre-set output file with _compiled and need a custom one, you can define it like one of the following options:

$ ./js-build source.js output.js
$ ./js-build-watcher source.js output.js

That creates (or overrides) the output.js file, which is stored in the same directory as the defined source.js.

Possible Features/Improvements

  • include complete sub directories
  • clean up the include keyword in js-build.sh
  • allow users to set output file
  • clear error messages
  • run build after watcher started
  • get rid of .sh
  • ignore common file headers
  • more/easier configuration

About

Linux based build tool for JavaScript to include source files into each other.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published