#!/bin/bash # Check that node exists and refers to nodejs global checknodejs := $[hash node !2 > /dev/null && node --help | grep js] if [[ $? -ne 0 ]] { echo 'NodeJS (node) is not properly installed' echo 'Note, on Ubuntu / Debian, you may need to also install:' echo '$ sudo apt-get install nodejs-legacy' exit 1 } # Check that npm is installed global checknpm := $[hash npm !2 > /dev/null] if [[ $? -ne 0 ]] { echo 'Node Package Manager (npm) is not properly installed' exit 1 } # Check for Chrome Canary on Ubuntu # The default install path is sometimes google-chrome-unstable # instead of google-chrome-canary as karma expects. if [[ "$OSTYPE" == "linux-gnu" ]] && [[ -z "$CHROME_CANARY_BIN" ]] { global checkcanary := $[hash google-chrome-canary !2 > /dev/null] if [[ $? -ne 0 ]] { global checkunstable := $[hash google-chrome-unstable !2 > /dev/null] if [[ $? -ne 0 ]] { echo 'Chrome Canary is not found' echo 'Please install and/or set CHROME_CANARY_BIN to its path' exit 1 } else { export CHROME_CANARY_BIN=google-chrome-unstable } } } npm install npm test (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:checknodejs) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (AndOr children: [ (SimpleCommand words: [{(hash)} {(node)}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [13] ) ] ) (Pipeline children: [(C {(node)} {(--help)}) (C {(grep)} {(js)})] negated: False ) ] op_id: Op_DAmp ) ] ) left_token: spids: [8 28] ) } spids: [7] ) ] spids: [7] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_ne left:{($ VSub_QMark "$?")} right:{(0)}) ) terminator: ) ] action: [ (C {(echo)} {(SQ <"NodeJS (node) is not properly installed">)}) (C {(echo)} {(SQ <"Note, on Ubuntu / Debian, you may need to also install:">)}) (C {(echo)} {(SQ <"$ sudo apt-get install nodejs-legacy">)}) (C {(exit)} {(1)}) ] spids: [-1 43] ) ] spids: [-1 71] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:checknpm) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [{(hash)} {(npm)}] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[83])] ) ] ) left_token: spids: [78 86] ) } spids: [77] ) ] spids: [77] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_ne left:{($ VSub_QMark "$?")} right:{(0)}) ) terminator: ) ] action: [ (C {(echo)} {(SQ <"Node Package Manager (npm) is not properly installed">)}) (C {(exit)} {(1)}) ] spids: [-1 101] ) ] spids: [-1 115] ) (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$OSTYPE"))} right: {(DQ (linux-gnu))} ) ) (DBracket expr: (BoolUnary op_id: BoolUnary_z child: {(DQ ($ VSub_Name "$CHROME_CANARY_BIN"))} ) ) ] op_id: Op_DAmp ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:checkcanary) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [{(hash)} {(google-chrome-canary)}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [165] ) ] ) ] ) left_token: spids: [160 168] ) } spids: [159] ) ] spids: [159] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_ne left:{($ VSub_QMark "$?")} right:{(0)}) ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:checkunstable) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [{(hash)} {(google-chrome-unstable)}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [193] ) ] ) ] ) left_token: spids: [188 196] ) } spids: [187] ) ] spids: [187] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_ne left: {($ VSub_QMark "$?")} right: {(0)} ) ) terminator: ) ] action: [ (C {(echo)} {(SQ <"Chrome Canary is not found">)}) (C {(echo)} {(SQ <"Please install and/or set CHROME_CANARY_BIN to its path">)} ) (C {(exit)} {(1)}) ] spids: [-1 212] ) ] else_action: [ (C {(export)} {(Lit_VarLike "CHROME_CANARY_BIN=") (google-chrome-unstable)}) ] spids: [234 243] ) ] spids: [-1 184] ) ] spids: [-1 246] ) ] spids: [-1 156] ) ] spids: [-1 248] ) (C {(npm)} {(install)}) (C {(npm)} {(test)}) ] )