Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Add support for xml plist #542

Closed
wants to merge 1 commit into from
Closed
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
28 changes: 27 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"dependencies": {
"bplist-creator": "0.0.8",
"bplist-parser": "^0.2.0",
"plist": "^3.0.1",
"tslib": "~1.12.0",
"uuid": "^3.3.2"
},
Expand Down
20 changes: 14 additions & 6 deletions scripts/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ const fs = require('fs').promises;
const util = require('util');

const bplist = require('bplist-parser');
const plist = require('plist');
const commandLineArgs = require('command-line-args')
const inquirer = require('inquirer');

const parseBplist = util.promisify(bplist.parseFile);
const parseBplist = bplist.parseBuffer;

const BPLIST_HEADER = 'bplist';

const optionDefinitions = [
{
Expand Down Expand Up @@ -37,11 +40,16 @@ const run = async () => {
file = `./shortcuts/${fileName}`;
}

const data = await parseBplist(file);


// If data is an array, use the first element
let shortcut = Array.isArray(data) ? data[0] : data;
let shortcut;
const buffer = await fs.readFile(file);
const header = buffer.slice(0, BPLIST_HEADER.length);
if (BPLIST_HEADER === header.toString('utf-8')) {
const data = parseBplist(buffer);
// If data is an array, use the first element
shortcut = Array.isArray(data) ? data[0] : data;
} else {
shortcut = plist.parse(buffer.toString('utf-8'));
}

const actions = shortcut.WFWorkflowActions;

Expand Down