-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·54 lines (48 loc) · 1.77 KB
/
Copy pathindex.js
File metadata and controls
executable file
·54 lines (48 loc) · 1.77 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env node
var extendscriptr = require('commander');
var packageJson = require('./package.json');
var browserify = require('browserify');
var prependify = require('prependify');
var fs = require('fs');
extendscriptr
.version(packageJson.version)
.usage('[options]')
.option('-s, --script <path>', 'The input file to compile into an executable extendscript')
.option('-o, --output <path>', 'The path to the wished compiled output file')
.option('-t, --target [targetApp]', 'The Adobe Application the script is intended for. i.e. InDesign [targetApp]')
.parse(process.argv);
console.log('Running extendscriptr with following options:');
extendscriptr.options.forEach(function(opt) {
if (opt.long === '--version') return;
var optionName = opt.long.replace('--', '');
console.log(
opt.long + ': ' +
extendscriptr[optionName] +
(opt.optional === 0 ? '' : ' (optional)')
);
});
var prototypePolyfills = fs.readFileSync('./node_modules/extendscript.prototypes/lib/extendscript.prototypes.js');
var browserifyPlugins = [ [ prependify, prototypePolyfills ] ];
var adobeTarget = String(extendscriptr.target).toLowerCase();
if ( adobeTarget &&
(adobeTarget.indexOf('indesign') >= 0 ||
adobeTarget.indexOf('photoshop') >= 0 ||
adobeTarget.indexOf('illustrator') >= 0 ||
adobeTarget.indexOf('aftereffects') >= 0)) {
browserifyPlugins.push([ prependify, '#target ' + extendscriptr.target + '\n' ]);
}
var b = browserify({
entries: [ extendscriptr.script ],
transform: [['babelify', {
presets: [
'es2015'
],
plugins: [
'babel-plugin-transform-es3-member-expression-literals',
'babel-plugin-transform-es3-property-literals',
'babel-plugin-transform-es5-property-mutators'
]
}]],
plugin: browserifyPlugins
});
b.bundle().pipe(fs.createWriteStream(extendscriptr.output));