Created
October 28, 2018 15:47
-
-
Save taoyuan/7782b709db494c6f0ffbc1452a6dd9c9 to your computer and use it in GitHub Desktop.
Pack the nodejs application using `pkg`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pack the nodejs application using `pkg` (https://github.com/zeit/pkg) | |
# dependencies: rimraf, cpx and pkg | |
# > npm i rimraf cpx pkg -D | |
.PHONY: init clean build | |
OS := $(shell uname) | |
ARCH := $(shell uname -p) | |
all: dist | |
init: | |
ifndef OS | |
@echo "Can not detect OS or not supported" | |
@exit 1 | |
endif | |
ifeq ($(OS),Windows) | |
PLATFORM := win | |
endif | |
ifeq ($(OS),Darwin) | |
PLATFORM := macos | |
endif | |
ifeq ($(OS),Linux) | |
PLATFORM := linux | |
endif | |
ifndef PLATFORM | |
@echo "Platform $(OS) is not supported" | |
@exit 1 | |
endif | |
DIST_PLATFORM := ./dist/$(PLATFORM)-$(ARCH) | |
clean: | |
npx rimraf lib dist | |
lib: | |
# build typescript | |
npm run build | |
build: clean lib | |
dist: init build | |
mkdir -p $(DIST_PLATFORM) | |
npx cpx "node_modules/**/*.node" $(DIST_PLATFORM)/node_modules | |
cp process.dist.yml $(DIST_PLATFORM)/process.yml | |
npx pkg . -o $(DIST_PLATFORM)/pinestd | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment