Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
wollardj committed Nov 7, 2019
2 parents dd93231 + 247f8ce commit 87e6728
Show file tree
Hide file tree
Showing 6 changed files with 2,008 additions and 1,721 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: node_js

node_js:
- 6
- 8
- 10
- 12

script:
- npm run test:verbose
65 changes: 37 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,74 @@
node-simple-plist
=================
# node-simple-plist

[![Build Status](https://api.travis-ci.com/wollardj/node-simple-plist.svg?branch=develop)](https://travis-ci.com/wollardj/node-simple-plist)
[![npm](https://img.shields.io/npm/dw/simple-plist.svg?style=popout&logo=npm)](https://www.npmjs.org/package/simple-plist)
[![npm](https://img.shields.io/npm/v/simple-plist.svg?style=popout&logo=npm)](https://www.npmjs.com/package/simple-plist)
[![Travis (.com) branch](https://img.shields.io/travis/com/wollardj/node-simple-plist/develop.svg?style=popout&logo=Travis%20CI)](https://travis-ci.com/wollardj/node-simple-plist)

A simple API for interacting with binary and plain text plist data.


## Installation

```sh
$ npm install simple-plist
```


## Reading Data

```js
var plist = require('simple-plist');
var plist = require('simple-plist')

// Read data from a file (xml or binary) (asynchronous)
plist.readFile('/path/to/some.plist', function(err,data){
if (err) {throw err;}
console.log( JSON.stringify(data) );
});
plist.readFile('/path/to/some.plist', function(err, data) {
if (err) {
throw err
}
console.log(JSON.stringify(data))
})

// Read data from a file (xml or binary) (synchronous)
var data = plist.readFileSync('/path/to/some.plist');
console.log( JSON.stringify(data) );
var data = plist.readFileSync('/path/to/some.plist')
console.log(JSON.stringify(data))
```


## Writing Data

```js
var plist = require('simple-plist'),
data = plist.readFileSync('/path/to/some.plist');
data = plist.readFileSync('/path/to/some.plist')

// Write data to a xml file (asynchronous)
plist.writeFile('/path/to/plaintext.plist', data, function(err){
if (err) { throw err; }
});
plist.writeFile('/path/to/plaintext.plist', data, function(err) {
if (err) {
throw err
}
})

// Write data to a xml file (synchronous)
plist.writeFileSync('/path/to/plaintext.plist', data);
plist.writeFileSync('/path/to/plaintext.plist', data)

// Write data to a binary plist file (asynchronous)
plist.writeBinaryFile('/path/to/binary.plist', data, function(err){
if (err) { throw err; }
});
plist.writeBinaryFile('/path/to/binary.plist', data, function(err) {
if (err) {
throw err
}
})

// Write data to a binary plist file (synchronous)
plist.writeBinaryFileSync('/path/to/binary.plist', data);
plist.writeBinaryFileSync('/path/to/binary.plist', data)
```


## Mutating Plists In Memory

```js
var plist = require('simple-plist');
var plist = require('simple-plist')

// Convert a Javascript object to a plist xml string
var xml = plist.stringify( {name: "Joe", answer:42} );
console.log(xml); // output is a valid plist xml string
var xml = plist.stringify({ name: 'Joe', answer: 42 })
console.log(xml) // output is a valid plist xml string

// Convert a plist xml string or a binary plist buffer to a Javascript object
var data = plist.parse("<plist><dict><key>name</key><string>Joe</string></dict></plist>");
console.log( JSON.stringify(data) );
var data = plist.parse(
'<plist><dict><key>name</key><string>Joe</string></dict></plist>'
)
console.log(JSON.stringify(data))
```
2 changes: 1 addition & 1 deletion __tests__/catch-invalid-plist.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ it('Throws an error on improperly formatted plist', () => {
function doIt() {
return plist.readFileSync(`${__dirname}/test-xml1-invalid.plist`)
}
expect(doIt).toThrow(/has errors$/)
expect(doIt).toThrow()
})

it('returns an empty object when the file is zero bytes', () => {
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "https://github.com/wollardj/node-simple-plist.git"
},
"version": "1.0.0",
"version": "1.1.0",
"description": "A wrapper utility for interacting with plist data.",
"main": "simple-plist.js",
"files": [
Expand Down Expand Up @@ -40,22 +40,22 @@
]
},
"dependencies": {
"bplist-creator": "0.0.7",
"bplist-parser": "0.1.1",
"bplist-creator": "0.0.8",
"bplist-parser": "0.2.0",
"plist": "^3.0.1"
},
"devDependencies": {
"eslint": "^5.9.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^3.3.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"husky": "^1.2.0",
"jest": "^23.6.0",
"lint-staged": "^8.1.0",
"eslint": "^6.6.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.16.0",
"husky": "^3.0.9",
"jest": "^24.9.0",
"lint-staged": "^9.4.2",
"npm-run-all": "^4.1.5",
"prettier": "^1.15.3",
"rimraf": "^2.6.2"
"prettier": "^1.18.2",
"rimraf": "^3.0.0"
}
}
2 changes: 1 addition & 1 deletion simple-plist.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function parse(aStringOrBuffer, aFile) {
throw new Error('Unable to determine format for plist aStringOrBuffer')
}
} catch (error) {
throw new Error(`${aFile} has errors`)
throw new Error(error)
}
return results
}
Expand Down

0 comments on commit 87e6728

Please sign in to comment.