Skip to content

Commit f3abe0e

Browse files
author
Steve Ross
authored
Merge pull request #13 from steve-ross/develop
Merging features from develop for release 0.3.0
2 parents 4eab260 + e004d80 commit f3abe0e

File tree

2 files changed

+47
-25
lines changed

2 files changed

+47
-25
lines changed

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,30 @@ clone the repo and link the helpers manually to the location you cloned the proj
6565
Steps to Test self-update
6666
1. add anything to the .helpers-version file (so they don't match current)
6767
2. adjust the timestamp/lastupdated time of .helpers-version so the file is older than 24 hours `touch -mt 200801120000 .helpers-version`
68+
69+
### Change Log / Release Notes
70+
71+
- Version 0.3.0
72+
- Export NPM_PACKAGE_NAME NPM_PACKAGE_VERSION
73+
- Date Detect - Handle non-mac environments (Thx for the PR!)
74+
- Version 0.2.0
75+
- auto detect shopify, bigcommerce, envkey
76+
- automatically download stencil file from EnvKey if we find the variable $STENCIL_FILE
77+
- depricate old helpers: requires_stencil, requires_themekit, requires_envkey
78+
- Version 0.1.0
79+
- check for updates and download when a new release is available
80+
- writes version string to .helpers-version in the same directory as helpers.sh
81+
- only check for a new version every 24h
82+
- added auto=detecting project types
83+
- look for .nvmrc and assume project is using nvm
84+
- look for .meteor directory and assume project is using meteor
85+
- don't call nvm use since direnv is loading node
86+
- abandon using log_error... just call _log error "something bad happened..."
87+
- Version 0.0.4
88+
- detect yarn.lock vs package-lock.json and install yarn if needed
89+
- Version 0.0.3
90+
- bugfix for when .nvmrc contains a release name ie: 'lts/dubnium'
91+
- Version 0.0.2
92+
- don't assume 'layout node' when using node
93+
- Version 0.0.1
94+
- Initial release

helpers.sh

+20-25
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
11
#!/usr/bin/env bash
22

3-
# Release Notes
4-
# Version 0.2.0
5-
# - auto detect shopify, bigcommerce, envkey
6-
# - automatically download stencil file from EnvKey if we find the variable $STENCIL_FILE
7-
# - depricate old helpers: requires_stencil, requires_themekit, requires_envkey
8-
# Version 0.1.0
9-
# - check for updates and download when a new release is available
10-
# - writes version string to .helpers-version in the same directory as helpers.sh
11-
# - only check for a new version every 24h
12-
# - added auto=detecting project types
13-
# - look for .nvmrc and assume project is using nvm
14-
# - look for .meteor directory and assume project is using meteor
15-
# - don't call nvm use since direnv is loading node
16-
# - abandon using log_error... just call _log error "something bad happened..."
17-
# Version 0.0.4
18-
# - detect yarn.lock vs package-lock.json and install yarn if needed
19-
# Version 0.0.3
20-
# - bugfix for when .nvmrc contains a release name ie: 'lts/dubnium'
21-
# Version 0.0.2
22-
# - don't assume 'layout node' when using node
23-
# Version 0.0.1
24-
# - Initial release
25-
26-
273
REPO_URL="https://api.github.com/repos/steve-ross/direnv-helpers/releases/latest"
284

295
__prompt_install_nvm(){
@@ -149,7 +125,11 @@ _log() {
149125
function comparedate() {
150126
local MAXAGE=$(bc <<< '24*60*60') # seconds in 24 hours
151127
# file age in seconds = current_time - file_modification_time.
152-
local FILEAGE=$(($(date +%s) - $(stat -f '%m' "$1")))
128+
if [ $(uname -s) == "Darwin" ]; then
129+
local FILEAGE=$(($(date +%s) - $(stat -f '%m' "$1")))
130+
else
131+
local FILEAGE=$(($(date +%s) - $(stat -c '%Y' "$1")))
132+
fi
153133
test $FILEAGE -gt $MAXAGE && {
154134
echo "Time to check for an update..."
155135
}
@@ -249,6 +229,7 @@ __use_yarn(){
249229
fi
250230
else
251231
if [ ! -d ./node_modules ]; then
232+
_log warn "Installing packages"
252233
# no node modules... install via yarn
253234
yarn
254235
fi
@@ -267,6 +248,7 @@ __requires_npm_or_yarn(){
267248
else
268249
if [ ! -d ./node_modules ]; then
269250
# no node modules... run npm install
251+
_log warn "Installing packages"
270252
npm install
271253
fi
272254
fi
@@ -360,6 +342,19 @@ layout_project(){
360342

361343
# if we have a package json do some node project detection
362344
if [[ -f "package.json" ]]; then
345+
# set some env vars that might be useful
346+
# package version
347+
export NPM_PACKAGE_VERSION=$(cat package.json \
348+
| grep version \
349+
| head -1 \
350+
| awk -F: '{ print $2 }' \
351+
| sed 's/[",]//g')
352+
# package name
353+
export NPM_PACKAGE_NAME=$(cat package.json \
354+
| grep name \
355+
| head -1 \
356+
| awk -F: '{ print $2 }' \
357+
| sed 's/[",]//g')
363358
# if directory has .nvmrc assume nvm/node project
364359
if [[ -f ".nvmrc" ]]; then
365360
layout_nvm

0 commit comments

Comments
 (0)