Skip to content

Commit

Permalink
Add browser-friendly variant of function suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Alhadis committed Mar 16, 2017
1 parent a7ad41d commit 045c39d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
node_modules
/browser.js
/index.js
*.log
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
all: index.js

\n := $$'\n'
ob := (

targets := index.js browser.js
node-only := $(shell grep -irwF lib -e 'require$(ob)' | cut -d : -f 1 | uniq)
browser := $(filter-out $(node-only),$(wildcard lib/*.js))

all: $(targets)

# Generate a compiled suite of functions from lib/*.js. Assumes Node environment.
index.js: $(wildcard lib/*.js) lib/classes/pattern-lists.js
@echo '"use strict";' > $@
@cat $^ | sed -Ee '/"use strict";$$/d' >> $@
Expand All @@ -11,7 +17,12 @@ index.js: $(wildcard lib/*.js) lib/classes/pattern-lists.js
| sed -e 's/^/\t/g; s/$$/,/g;' >> $@;
@printf "};"$(\n) >> $@;

# Generate browser-compatible version of function suite
browser.js: $(browser)
@echo '"use strict";' > $@
@cat $^ | sed -Ee '/"use strict";$$/d' >> $@

clean:
@rm -f index.js
@rm -f $(targets)

.PHONY: clean
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@Alhadis/Utils",
"version": "v0.0.0",
"files": ["./index.js"],
"main": "./index.js",
"files": ["./index.js", "./browser.js"],
"description": "Battle-hardened suite of self-contained utility functions.",
"keywords": ["utility", "helper", "functional", "utils", "browser", "atom"],
"repository": "https://github.com/Alhadis/Utils",
Expand Down

0 comments on commit 045c39d

Please sign in to comment.