Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-nodejs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-nodejs
Commits
2be1b8d8
Unverified
Commit
2be1b8d8
authored
Jan 24, 2019
by
Jeremy Morrell
Committed by
GitHub
Jan 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move more files to shellcheck (#605)
* Add lib/build-data.sh and lib/cache.sh to shellcheck
parent
e2a1b61c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
23 deletions
+30
-23
compile
bin/compile
+6
-6
build-data.sh
lib/build-data.sh
+8
-4
cache.sh
lib/cache.sh
+15
-12
makefile
makefile
+1
-1
No files found.
bin/compile
View file @
2be1b8d8
...
...
@@ -165,8 +165,8 @@ install_bins | output "$LOG_FILE"
restore_cache
()
{
local
cache_status cache_directories
cache_status
=
"
$(
get_cache_status
)
"
cache_directories
=
"
$(
get_cache_directories
)
"
cache_status
=
"
$(
get_cache_status
"
$CACHE_DIR
"
)
"
cache_directories
=
"
$(
get_cache_directories
"
$BUILD_DIR
"
)
"
if
$YARN
;
then
if
[
-e
"
$BUILD_DIR
/node_modules"
]
;
then
...
...
@@ -213,7 +213,7 @@ build_dependencies() {
run_if_present
'heroku-prebuild'
cache_status
=
"
$(
get_cache_status
)
"
cache_status
=
"
$(
get_cache_status
"
$CACHE_DIR
"
)
"
start
=
$(
nowms
)
if
$YARN
;
then
...
...
@@ -243,9 +243,9 @@ build_dependencies | output "$LOG_FILE"
cache_build
()
{
local
cache_directories
cache_directories
=
"
$(
get_cache_directories
)
"
cache_directories
=
"
$(
get_cache_directories
"
$BUILD_DIR
"
)
"
clear_cache
clear_cache
"
$CACHE_DIR
"
if
!
${
NODE_MODULES_CACHE
:-
true
}
;
then
# we've already warned that caching is disabled in the restore step
# so be silent here
...
...
@@ -257,7 +257,7 @@ cache_build() {
header
"Caching build"
save_custom_cache_directories
"
$BUILD_DIR
"
"
$CACHE_DIR
"
"
$cache_directories
"
fi
save_signature
save_signature
"
$CACHE_DIR
"
}
cache_build | output
"
$LOG_FILE
"
...
...
lib/build-data.sh
View file @
2be1b8d8
#!/usr/bin/env bash
# variable shared by this whole module
BUILD_DATA_FILE
=
""
bd_create
()
{
local
cache_dir
=
"
$1
"
BUILD_DATA_FILE
=
"
$cache_dir
/build-data/node"
kv_create
$BUILD_DATA_FILE
kv_create
"
$BUILD_DATA_FILE
"
}
bd_get
()
{
kv_get
$BUILD_DATA_FILE
"
$1
"
kv_get
"
$BUILD_DATA_FILE
"
"
$1
"
}
bd_set
()
{
kv_set
$BUILD_DATA_FILE
"
$1
"
"
$2
"
kv_set
"
$BUILD_DATA_FILE
"
"
$1
"
"
$2
"
}
log_build_data
()
{
# print all values on one line in logfmt format
# https://brandur.org/logfmt
echo
$(
kv_list
$BUILD_DATA_FILE
)
# the echo call ensures that all values are printed on a single line
# shellcheck disable=SC2005 disable=SC2046
echo
$(
kv_list
"
$BUILD_DATA_FILE
"
)
}
lib/cache.sh
View file @
2be1b8d8
#!/usr/bin/env bash
source
$BP_DIR
/lib/binaries.sh
create_signature
()
{
echo
"v2;
${
STACK
}
;
$(
node
--version
)
;
$(
npm
--version
)
;
$(
yarn
--version
2>/dev/null
||
true
)
;
${
PREBUILD
}
"
}
save_signature
()
{
create_signature
>
$CACHE_DIR
/node/signature
local
cache_dir
=
"
$1
"
create_signature
>
"
$cache_dir
/node/signature"
}
load_signature
()
{
if
test
-f
$CACHE_DIR
/node/signature
;
then
cat
$CACHE_DIR
/node/signature
local
cache_dir
=
"
$1
"
if
test
-f
"
$cache_dir
/node/signature"
;
then
cat
"
$cache_dir
/node/signature"
else
echo
""
fi
}
get_cache_status
()
{
local
cache_dir
=
"
$1
"
if
!
${
NODE_MODULES_CACHE
:-
true
}
;
then
echo
"disabled"
elif
!
test
-d
"
$
{
CACHE_DIR
}
/node/"
;
then
elif
!
test
-d
"
$
cache_dir
/node/"
;
then
echo
"not-found"
elif
[
"
$(
create_signature
)
"
!=
"
$(
load_signature
)
"
]
;
then
elif
[
"
$(
create_signature
)
"
!=
"
$(
load_signature
"
$cache_dir
"
)
"
]
;
then
echo
"new-signature"
else
echo
"valid"
...
...
@@ -31,9 +32,10 @@ get_cache_status() {
}
get_cache_directories
()
{
local
build_dir
=
"
$1
"
local
dirs1 dirs2
dirs1
=
$(
read_json
"
$
BUILD_DIR
/package.json"
".cacheDirectories | .[]?"
)
dirs2
=
$(
read_json
"
$
BUILD_DIR
/package.json"
".cache_directories | .[]?"
)
dirs1
=
$(
read_json
"
$
build_dir
/package.json"
".cacheDirectories | .[]?"
)
dirs2
=
$(
read_json
"
$
build_dir
/package.json"
".cache_directories | .[]?"
)
if
[
-n
"
$dirs1
"
]
;
then
echo
"
$dirs1
"
...
...
@@ -88,9 +90,10 @@ restore_custom_cache_directories() {
}
clear_cache
()
{
rm
-rf
$CACHE_DIR
/node
mkdir
-p
$CACHE_DIR
/node
mkdir
-p
$CACHE_DIR
/node/cache
local
cache_dir
=
"
$1
"
rm
-rf
"
$cache_dir
/node"
mkdir
-p
"
$cache_dir
/node"
mkdir
-p
"
$cache_dir
/node/cache"
}
save_default_cache_directories
()
{
...
...
makefile
View file @
2be1b8d8
...
...
@@ -2,7 +2,7 @@ test: heroku-18 heroku-16 cedar-14
shellcheck
:
@
shellcheck
-x
bin/compile bin/detect bin/release bin/test bin/test-compile
@
shellcheck
-x
lib/binaries.sh
@
shellcheck
-x
lib/binaries.sh
lib/build-data.sh lib/cache.sh
@
echo
TODO shellcheck
-x
lib/
**
/
*
.sh
@
echo
TODO shellcheck
-x
ci-profile/
**
/
*
.sh
@
echo
TODO shellcheck
-x
etc/
**
/
*
.sh
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment