Can I run shell scripts in HyperDev?


#1

I have a shell script that I want to run via npm start, and have my package.json’s scripts.start executing that file, but I get a permissions error:

/app/bin/start: line 20: ./script/start.sh: Permission denied 11:33 AM

Here’s the contents of start.sh

#!/bin/bash

set -e

# # this script decides whether or not to start 
# server in harmony mode, depending on Node
# version.

MAX_HARMONY_VERSION=5
NODE_VERSION=$(node -v | grep -o 'v[0-9]')
HARMONY_FLAGS=""

if [[ ${NODE_VERSION:1:1} -le $MAX_HARMONY_VERSION ]]; then
	echo "Running with harmony for select es6 support"
	$HARMONY_FLAGS="--harmony --harmony_destructuring"
fi

# echo "Starting server"
node $HARMONY_FLAGS server.js

Does HyperDev not support shell scripts?


#2

I managed to make Dart work with a shell script (see here). package.json contains:

"scripts": {
	"start": "bash ./setup-and-launch.sh"
}

and the .sh file looks much like yours:

#!/bin/bash

# Set up Dart if it doesn't exist
if [ ! -f ~/dart-sdk/bin/dart ]; then

  # Download if not already downloaded
  if [ ! -f ~/dart.tar.gz ]; then
    echo "Downloading Dart..."
    curl -Lo ~/dart.tar.gz https://github.com/DanTup/Misc/releases/download/v1/dart-sdk.tar.gz
  fi

  # Extract  
  echo "Extracting Dart..."
  tar xzf ~/dart.tar.gz -C ~

fi

echo "Launching Dart..."
~/dart-sdk/bin/dart ~/src/server.dart

I’m not sure exactly what’s different between mine and yours (nor do I know if this is intended to be supported), but the Dart sample still seems to work today :slight_smile:


#3

Thanks @DanTup.

In my package.json, i just had ./script/start.sh, not bash script/start.sh. The former (sans bash) works in my local dev environment (and presumably in prod) but not on HyperDev. Looks like HyperDev wants to see bash.


#4

Hi Benjamin,

All files in the editor are created with “read/write” permissions, but no “exec” permissions: it means that you cannot treat them as executables. However, you can pass them to an interpreter/executor, bash, in your case.