Comparing version 1.5.1 to 1.6.0
{ | ||
"name": "jsxbin", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"description": "Convert jsx ExtendScript files into jsxbin files using ExtendScript Toolkit", | ||
@@ -30,5 +30,5 @@ "keywords": [ | ||
"dependencies": { | ||
"command-line-args": "^4.0.2", | ||
"command-line-args": "^4.0.4", | ||
"command-line-usage": "^4.0.0", | ||
"glob": "^7.1.1", | ||
"glob": "^7.1.2", | ||
"mkdirp": "^0.5.1", | ||
@@ -39,5 +39,5 @@ "tmp-promise": "^1.0.3", | ||
"devDependencies": { | ||
"eslint": "^3.18.0", | ||
"eslint-config-runegan": "^1.0.0", | ||
"mocha": "^3.2.0", | ||
"eslint": "^3.19.0", | ||
"eslint-config-runegan": "^1.0.1", | ||
"mocha": "^3.4.1", | ||
"mz": "^2.6.0", | ||
@@ -44,0 +44,0 @@ "rimraf": "^2.6.1" |
const exec = require( 'child_process' ).exec | ||
const fs = require( 'fs' ) | ||
const path = require( 'path' ) | ||
const log = require( './logger' ) | ||
module.exports = function doScriptFiles( files ) { | ||
let chain = Promise.resolve() | ||
files.forEach( file => { | ||
chain = chain.then( () => doScriptFile( file ) ) | ||
}) | ||
return chain | ||
} | ||
function doScriptFile( file ) { | ||
module.exports = function doScriptFile( file ) { | ||
// An alert comes from ESTK if it already open when running the command | ||
@@ -23,21 +15,22 @@ // So we need to close it before running the command | ||
function execute( file ) { | ||
const command = getESTKCommand( file ) | ||
const command = getESTKCommand( path.basename( file ) ) | ||
const scriptDir = path.dirname( file ) | ||
log.verbose( 'Converting' ) | ||
log.debug( 'Command: ', command ) | ||
log.verbose( 'Converting' ) | ||
log.debug( 'Command: ', command ) | ||
// Execute the command | ||
return execPromise( command ) | ||
// Execute the command | ||
return execPromise( command, scriptDir ) | ||
} | ||
function execPromise( command ) { | ||
return new Promise( ( resolve, reject ) => { | ||
// Execute the command | ||
exec( command, err => { | ||
if ( err ) { | ||
return reject( err ) | ||
} | ||
resolve() | ||
}) | ||
}) | ||
function execPromise( command, scriptDir ) { | ||
return new Promise( ( resolve, reject ) => { | ||
// Execute the command | ||
exec( command, { cwd: scriptDir }, err => { | ||
if ( err ) { | ||
return reject( err ) | ||
} | ||
resolve() | ||
}) | ||
}) | ||
} | ||
@@ -54,3 +47,3 @@ | ||
if ( process.platform === 'darwin' ) { | ||
path = checkPaths( '/Applications/Adobe ExtendScript Toolkit CC/ExtendScript Toolkit.app/Contents/MacOS/ExtendScript Toolkit', | ||
path = checkPaths( | ||
'/Applications/Adobe ExtendScript Toolkit CC/ExtendScript Toolkit.app/Contents/MacOS/ExtendScript Toolkit', | ||
@@ -62,3 +55,4 @@ '/Applications/Utilities/Adobe Utilities - CS6.localized/ExtendScript Toolkit CS6/ExtendScript Toolkit.app/Contents/MacOS/ExtendScript Toolkit' | ||
} else if ( process.platform === 'win32' ) { | ||
path = checkPaths( 'C:\\Program Files (x86)\\Adobe\\Adobe ExtendScript Toolkit CC\\ExtendScript Toolkit.exe', | ||
path = checkPaths( | ||
'C:\\Program Files (x86)\\Adobe\\Adobe ExtendScript Toolkit CC\\ExtendScript Toolkit.exe', | ||
'C:\\Program Files (x86)\\Adobe\\Adobe ExtendScript Toolkit\\ExtendScript Toolkit.exe' | ||
@@ -65,0 +59,0 @@ ) |
const tmp = require( 'tmp-promise' ) | ||
const writeFile = require( 'fs' ).writeFile | ||
const path = require( 'path' ) | ||
const log = require( './logger' ) | ||
module.exports = function generateScriptFiles( inputs, outputs ) { | ||
const list = generateInputList( inputs, outputs ) | ||
const scripts = [] | ||
Object.keys( list ).forEach( dir => { | ||
const { input, output } = list[dir] | ||
const script = generateScriptFile( dir, input, output ) | ||
scripts.push( script ) | ||
}) | ||
return Promise.all( scripts ) | ||
} | ||
function generateScriptFile( dir, input, output ) { | ||
module.exports = function generateScriptFile( input, output ) { | ||
// We need to create a temp file that ESTK can run, this file will have | ||
// all paths that are going to be converted | ||
return tmp.file({ dir, postfix: '.jsx' }) | ||
return tmp.file({ postfix: '.jsx' }) | ||
@@ -77,4 +63,8 @@ // "tmp.file" returns an object with the more properties, but we are only | ||
// Convert it to jsxbin format | ||
var t = app.compile( s ); | ||
// Set the include path | ||
// From 80document.jsx in ESTK / RenderTom (issue #5) | ||
var includepath = fileIn.parent ? fileIn.parent.absoluteURI : "/" | ||
var t = app.compile( s, fileIn.absoluteURI, includepath ); | ||
// Write it to output file | ||
@@ -94,20 +84,1 @@ fileOut.open( "w" ); | ||
} | ||
function generateInputList( inputs, outputs ) { | ||
const dirs = {} | ||
inputs.forEach( ( input, index ) => { | ||
const dirname = path.dirname( input ) | ||
if ( !dirs[dirname] ) { | ||
dirs[dirname] = { | ||
input: [], | ||
output: [] | ||
} | ||
} | ||
const output = outputs[index] | ||
dirs[dirname].input.push( input ) | ||
dirs[dirname].output.push( output ) | ||
}) | ||
return dirs | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16485
389
Updatedcommand-line-args@^4.0.4
Updatedglob@^7.1.2