Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ Copyright (c) 2014 Jonathan Wiesel

# Contributors :heart:

* [claui](https://github.com/claui)
* [claui](https://github.com/claui)
* [@danielbayley](https://github.com/danielbayley)
1 change: 1 addition & 0 deletions cmds/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = function(program) {

program
.command('install <bundleID>')
.alias('i')
.description('Install specified workflow.')
.action(function(bundleID, options){

Expand Down
1 change: 1 addition & 0 deletions cmds/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = function(program) {

program
.command('list')
.alias('ls')
.description('List installed workflows.')
.action(function(){

Expand Down
1 change: 1 addition & 0 deletions cmds/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = function(program) {

program
.command('remove <bundleID>')
.alias('rm')
.description('Remove specified workflow.')
.action(function(bundleID, options){

Expand Down
16 changes: 6 additions & 10 deletions lib/awm.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ var exec = require('child_process').exec;

var PACKAL_URL = 'https://raw.github.com/packal/repository/master/';
var MANIFEST_URL = PACKAL_URL + 'manifest.xml';
var LOCAL_STORAGE_DIR = process.env.HOME + '/.awm/';
var manifestFile = LOCAL_STORAGE_DIR + 'manifest.json';
var cacheDir = LOCAL_STORAGE_DIR + 'cached/';
var cacheDir = process.env.AWM_CACHE || process.env.HOME + '/Library/Caches/awm/';
var manifestFile = cacheDir + 'manifest.json';

var fetchAndParseManifest = function(callback) {

Expand Down Expand Up @@ -225,21 +224,19 @@ var getWorkflowDir = function(bundleId, callback) {

var getAlfredPreference = function(callback){

var alfredPref = process.env.HOME + '/Library/Preferences/com.runningwithcrayons.Alfred-Preferences.plist';
var alfredPref = process.env.HOME + '/Library/Preferences/com.runningwithcrayons.Alfred-Preferences*.plist';

var alfredNewStyle = process.env.HOME + '/Library/Preferences/com.runningwithcrayons.Alfred-Preferences-NewStyle.plist';

exec('plutil -convert xml1 ' + alfredPref + ' -o ' + alfredNewStyle, function(error){
exec('plutil -convert xml1 ' + alfredPref + ' -o -', function(error, data){

if(error){
console.error(('Cannot convert Alfred base preference file : \n' + error).red);
process.exit(1);

}else{

var prefFile = plist.parse(fs.readFileSync(alfredNewStyle, 'utf8'));
var prefs = plist.parse(data);

var location = (prefFile.syncfolder === undefined) ? process.env.HOME + '/Library/Application Support/Alfred 2' : prefFile.syncfolder.replace('~', process.env.HOME);
var location = (prefs.syncfolder === undefined) ? process.env.HOME + '/Library/Application Support/Alfred 3' : prefs.syncfolder.replace('~', process.env.HOME);

callback(location + '/Alfred.alfredpreferences/workflows/');
}
Expand All @@ -255,7 +252,6 @@ module.exports = {
getWorkflowDir: getWorkflowDir,
config: {
packalUrl: PACKAL_URL,
directory: LOCAL_STORAGE_DIR,
cacheDir: cacheDir,
manifest: manifestFile,
getAlfredPreference: getAlfredPreference
Expand Down
2 changes: 1 addition & 1 deletion scripts/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
var awm = require('../lib/awm');
var fs = require('fs-extra');

fs.removeSync(awm.config.directory);
fs.removeSync(awm.config.cacheDir);
process.exit();
9 changes: 3 additions & 6 deletions scripts/init.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
'use strict';

var awm = require('../lib/awm');
var fs = require('fs');
var fs = require('fs-extra');

if (!fs.existsSync(awm.config.directory)) {
fs.mkdirSync(awm.config.directory);
if(!fs.existsSync(awm.config.cacheDir)){
fs.mkdirSync(awm.config.cacheDir);
}
if (!fs.existsSync(awm.config.cacheDir)) {
fs.mkdirpSync(awm.config.cacheDir);
}

awm.fetchAndParseManifest(function(jsManifest){
Expand Down