-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·27 lines (23 loc) · 836 Bytes
/
index.js
File metadata and controls
executable file
·27 lines (23 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env node
const nodeJxa = require('./node-jxa');
const DEBUG_ENV_VAR = 'NODE_DEBUG_JXA';
const DEBUG_SWITCHES = [ '--debug', '-d' ];
module.exports = ( processArgs ) => {
const nonProcessArgs = processArgs.argv.slice( 2 ); // lose the 'node' and 'index.js'
const nonDebugSwitchArgs = nonProcessArgs.filter( arg => !DEBUG_SWITCHES.includes( arg )); // ignoring debug switch
const jxaScriptArg = nonDebugSwitchArgs[ 0 ];
if ( !jxaScriptArg ) {
console.error( 'error: no jxa script specified' );
} else {
nodeJxa(
jxaScriptArg,
{
debug:
['true', '1'].includes ( processArgs.env[ DEBUG_ENV_VAR ] )
||
!!(nonProcessArgs.filter( arg => DEBUG_SWITCHES.includes( arg )).length)
}
)
}
};
module.exports( { argv: process.argv, env: process.env } );