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

Can't load lib #4

Closed
nickbuddendotcom opened this issue Apr 2, 2015 · 1 comment
Closed

Can't load lib #4

nickbuddendotcom opened this issue Apr 2, 2015 · 1 comment

Comments

@nickbuddendotcom
Copy link

Having trouble loading the library, consistently getting an error.

Complied script placed here: https://cloudup.com/chgGvgXxRo0

Node app creating script here: var script = "of = Library('OmniFocus');"

Getting this error: err { [Error: 0:2: syntax error: A “of” can’t go here. (-2740) ] appleScript: 'of = Library(\'OmniFocus\');', exitCode: 1 }

@nickbuddendotcom
Copy link
Author

Fixed. For future reference on anyone trying to do this using Node AppleScript, my problem was using execString instead of execFile, and I was able to see my issue mostly in this repo: https://github.com/linclark/omnifocus-github. Here's a quick example for anyone doing a node app.

#!/usr/bin/env node

var applescript = require('applescript');
var sleep       = require('sleep');
var temp        = require('temp');
var fs          = require('fs');

temp.open('your-file-name', function(err, info) {
  if (err) {
    return;
  }

  var script = '';

  script += 'var of = Application(\'OmniFocus\');';
  script += 'var inbox = of.defaultDocument.inboxTasks;';
  script += 'var task = of.InboxTask({name: "testing"});';
  script += 'inbox.push(task);';

  fs.write(info.fd, script);

  fs.close(info.fd, function(err) {
    applescript.execFile(info.path, ["-lJavaScript"], function(err, rtn) {
      if(err) console.log(err);
    });
  });

});



Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant