Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
- error handling in json2.js -> throw error statement
- corrects file path to launcher script (Win)
  • Loading branch information
OliverGruenberg committed Apr 20, 2015
1 parent 6450c6d commit 5e8442c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/bin/node-win/porky.bat

This file was deleted.

5 changes: 5 additions & 0 deletions src/bin/porky.bat
@@ -0,0 +1,5 @@
@echo off
echo.
SET thisPath=%~dp0
"node.exe" "%thisPath:~0,-1%/porky-data-source-access.js"
pause
8 changes: 6 additions & 2 deletions src/lib/json-js/json2.js
Expand Up @@ -391,7 +391,9 @@ if (typeof JSON !== 'object') {
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
// throw new Error('JSON.stringify');
alert('Error JSON.stringify');
exit(0);
}

// Make a fake root object containing our value under the key of ''.
Expand Down Expand Up @@ -483,7 +485,9 @@ if (typeof JSON !== 'object') {

// If the text is not JSON parseable, then a SyntaxError is thrown.

throw new SyntaxError('JSON.parse');
// throw new SyntaxError('JSON.parse');
alert('Syntax error JSON.parse');
exit(0);
};
}
}());
2 changes: 1 addition & 1 deletion src/start-porky-data-source-access.jsx
@@ -1 +1 @@
/* Start porky data source access by launching this script from the InDesign scripts panel. OS-X: This JavaScript launches an AppleScript which launches a Terminal script which launches another JavaScript file with Apple's built-in Node.Js interpreter :-) Windows: This JavaScript launches a command line script which launches another JavaScript file with the Node.Js interpreter which can be downloaded at http://nodejs.org/download/ Installation: in order to run correctly, porky needs the following npm modules to be installed via terminal (Mac) or command line (Win): npm install request npm install sqlite3 npm install mysql npm install pg npm install xml2js npm install htmlparser npm install markdown npm install brucedown npm install html-entities*/// Definition of relative paths// No changes necessary here// Use only local paths, no network paths allowedvar thisParentFolder = File($.fileName).parent;var thisRootFolder = File("~").fsName;var thisAbsolutePath = thisParentFolder.toString().replace("~", thisRootFolder); thisAbsolutePath = Folder.decode(thisAbsolutePath).toString(); thisAbsolutePath = thisAbsolutePath.replace(/\\/, "/");var executeThis = "";if(File.fs == "Windows"){ alert("Attention Windows Users:\n\nThis launcher needs custom entries!\n\n-> download & install Node.Js binaries first\n-> install missing packages correctly.\n\nIf Node doesn't find its modules, check http://stackoverflow.com/questions/9587665/nodejs-cannot-find-installed-module-on-windows"); var porkyExecutableFilePathWin = thisAbsolutePath + "/bin/node-win/porky.bat"; executeThis = new File(porkyExecutableFilePathWin); executeThis.execute();}else if(File.fs == "Macintosh"){ var porkyExecutableFilePathMac = ''; porkyExecutableFilePathMac = "'" + thisAbsolutePath + "/bin/porky-data-source-access.js" + "'"; executeThis = "tell application \"Terminal\"\r do script with command \"node " + porkyExecutableFilePathMac + "\"\r activate\r end tell"; app.doScript(executeThis, ScriptLanguage.applescriptLanguage);}
/* Start porky data source access by launching this script from the InDesign scripts panel. OS-X: This JavaScript launches an AppleScript which launches a Terminal script which launches another JavaScript file with Apple's built-in Node.Js interpreter :-) Windows: This JavaScript launches a command line script which launches another JavaScript file with the Node.Js interpreter which can be downloaded at http://nodejs.org/download/ Installation: in order to run correctly, porky needs the following npm modules to be installed via terminal (Mac) or command line (Win): npm install request npm install sqlite3 npm install mysql npm install pg npm install xml2js npm install htmlparser npm install markdown npm install brucedown npm install html-entities*/// Definition of relative paths// No changes necessary here// Use only local paths, no network paths allowedvar thisParentFolder = File($.fileName).parent;var thisRootFolder = File("~").fsName;var thisAbsolutePath = thisParentFolder.toString().replace("~", thisRootFolder); thisAbsolutePath = Folder.decode(thisAbsolutePath).toString(); thisAbsolutePath = thisAbsolutePath.replace(/\\/, "/");var executeThis = "";if(File.fs == "Windows"){ alert("Attention Windows Users:\n\nThis launcher needs custom entries!\n\n-> download & install Node.Js binaries first\n-> install missing packages correctly.\n\nIf Node doesn't find its modules, check http://stackoverflow.com/questions/9587665/nodejs-cannot-find-installed-module-on-windows"); var porkyExecutableFilePathWin = thisAbsolutePath + "/bin/porky.bat"; executeThis = new File(porkyExecutableFilePathWin); executeThis.execute();}else if(File.fs == "Macintosh"){ var porkyExecutableFilePathMac = ''; porkyExecutableFilePathMac = "'" + thisAbsolutePath + "/bin/porky-data-source-access.js" + "'"; executeThis = "tell application \"Terminal\"\r do script with command \"node " + porkyExecutableFilePathMac + "\"\r activate\r end tell"; app.doScript(executeThis, ScriptLanguage.applescriptLanguage);}
Expand Down

0 comments on commit 5e8442c

Please sign in to comment.