Skip to content

Commit 516204d

Browse files
authored
Merge pull request #17 from edx/george/samples-make-target
Separate build and local preview of samples
2 parents 90ad82e + f406730 commit 516204d

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

Makefile

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,43 @@
22

33
.DEFAULT_GOAL := help
44

5+
NPM_BIN = $(shell npm bin)
6+
7+
# Generates a help message. Borrowed from https://github.com/pydanny/cookiecutter-djangopackage.
58
help: ## display this help message
69
@echo "Please use \`make <target>' where <target> is one of"
7-
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
10+
@perl -nle'print $& if m{^[\.a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
811

912
install: ## install requirements
1013
npm install
1114

1215
clean: ## remove build artifacts
13-
rm -rf css/
14-
rm -rf samples/css/
15-
rm -rf samples/edx-bootstrap/
16-
17-
samples: clean ## build the samples
18-
mkdir samples/edx-bootstrap
19-
cp -r sass/ samples/edx-bootstrap/sass
20-
mkdir samples/css
21-
mkdir samples/css/edx
22-
mkdir samples/css/open-edx
23-
./node_modules/node-sass/bin/node-sass samples/edx/sass --output samples/edx/css --include-path samples --include-path node_modules
24-
./node_modules/node-sass/bin/node-sass samples/open-edx/sass --output samples/open-edx/css --include-path samples --include-path node_modules
25-
./node_modules/.bin/opn samples/index.html
26-
27-
build: clean ## build the npm package
28-
29-
preview: samples ## build the preview site
30-
aws s3 sync samples s3://${S3_PREVIEW_DOMAIN}/$(shell git rev-parse --abbrev-ref HEAD)
31-
@echo Preview generated to http://${S3_PREVIEW_DOMAIN}/$(shell git rev-parse --abbrev-ref HEAD)
16+
rm -rf {css,samples/{css,edx-bootstrap}}
17+
18+
build.samples: clean ## build the samples
19+
$(eval $@_INCLUDE = --include-path samples --include-path node_modules)
20+
mkdir -p samples/edx-bootstrap
21+
mkdir -p samples/css/{edx,open-edx}
22+
cp -R sass/ samples/edx-bootstrap/sass
23+
$(NPM_BIN)/node-sass samples/edx/sass --output samples/edx/css $($@_INCLUDE)
24+
$(NPM_BIN)/node-sass samples/open-edx/sass --output samples/open-edx/css $($@_INCLUDE)
25+
26+
samples: clean build.samples ## build and show the samples
27+
$(NPM_BIN)/opn samples/index.html
28+
29+
preview: build.samples ## build the preview site
30+
$(eval $@_REF = $(shell git rev-parse --abbrev-ref HEAD))
31+
aws s3 sync samples s3://${S3_PREVIEW_DOMAIN}/$($@_REF)
32+
@echo Preview generated to http://${S3_PREVIEW_DOMAIN}/$($@_REF)
33+
$(NPM_BIN)/opn http://${S3_PREVIEW_DOMAIN}/$($@_REF)
3234

3335
quality:
34-
./node_modules/stylelint/bin/stylelint.js sass/**/*.scss samples/**/*.scss
36+
$(NPM_BIN)/stylelint sass/**/*.scss samples/**/*.scss
3537

3638
fix:
37-
./node_modules/stylelint/bin/stylelint.js sass/**/*.scss samples/**/*.scss --fix
39+
$(NPM_BIN)/stylelint sass/**/*.scss samples/**/*.scss --fix
3840

39-
test: clean quality ## run tests
41+
test: clean quality build.samples ## run tests
4042

4143
xxx:
42-
echo $(shell git rev-parse --abbrev-ref HEAD)
44+
echo $$(git rev-parse --abbrev-ref HEAD)

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)