Skip to content

Instantly share code, notes, and snippets.

@wordijp
Created May 14, 2020 14:48
Show Gist options
  • Save wordijp/853323f64ff7cdacabf862a14c40b9f9 to your computer and use it in GitHub Desktop.
Save wordijp/853323f64ff7cdacabf862a14c40b9f9 to your computer and use it in GitHub Desktop.
deno example by Makefile
// lib/foo.js
export default function() {
console.log('foo.js');
}
// lib/hoge/piyo.ts
export default function() {
console.log('piyo.ts modified');
}
// main.js
import foo from 'http://localhost:8000/lib/foo.js';
import piyo from 'http://localhost:8000/lib/hoge/piyo.ts';
foo();
piyo();
# https://stackoverflow.com/questions/2483182/recursive-wildcards-in-gnu-make
rwildcard=$(foreach d,$(wildcard $(1:=/*)), \
$(call rwildcard,$d,$2) \
$(filter $(subst *,%,$2),$d))
# http://www.jsk.t.u-tokyo.ac.jp/~k-okada/makefile/
empty:=
space:= $(empty) $(empty)
myjoin=$(subst $(space),$2,$1)
# --------------------------------------------------
LOCAL_ROOT = http://localhost:8000/
MAIN_SRC = main.js
LIB_SRCS = $(call rwildcard,lib,*.js *.ts)
LIB_SRCS := $(patsubst %, $(LOCAL_ROOT)%, $(LIB_SRCS))
LIB_SRCS := $(strip $(LIB_SRCS))
comma:= ,
LIB_SRCS := $(call myjoin,$(LIB_SRCS),$(comma))
# --------------------------------------------------
deno:
deno run --reload=$(LIB_SRCS) $(MAIN_SRC)
@wordijp
Copy link
Author

wordijp commented May 14, 2020

launch local server command example: python -m http.server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment