alfred-link
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -5,3 +5,5 @@ #!/usr/bin/env node | ||
if (process.env.npm_config_global === '') { | ||
const npmGlobal = process.env.npm_config_global; | ||
if (npmGlobal === '') { | ||
// Prevent linking if the script was part of a non-global npm (install) command | ||
@@ -11,5 +13,6 @@ process.exit(0); | ||
alfyLink().catch(err => { | ||
// Only transform if `alfred-link` is called from `npm -g` | ||
alfyLink({transform: npmGlobal}).catch(err => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
26
index.js
'use strict'; | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const pathExists = require('path-exists'); | ||
const pkgUp = require('pkg-up'); | ||
const pify = require('pify'); | ||
const del = require('del'); | ||
const readPkgUp = require('read-pkg-up'); | ||
const resolveAlfredPrefs = require('resolve-alfred-prefs'); | ||
const plistTransform = require('./lib/plist-transform'); | ||
const link = require('./lib/link'); | ||
const fsP = pify(fs); | ||
module.exports = opts => { | ||
const options = Object.assign({ | ||
transform: true | ||
}, opts); | ||
module.exports = () => { | ||
const cwd = process.cwd(); | ||
@@ -29,6 +29,7 @@ | ||
return pkgUp(cwd); | ||
return readPkgUp(cwd); | ||
}) | ||
.then(filePath => { | ||
const pkg = require(filePath); | ||
.then(result => { | ||
const pkg = result.pkg; | ||
const filePath = result.path; | ||
@@ -38,6 +39,9 @@ const src = path.dirname(filePath); | ||
if (!options.transform) { | ||
return link(src, dest); | ||
} | ||
return plistTransform(path.dirname(filePath), pkg) | ||
.then(() => del(dest, {force: true})) | ||
.then(() => fsP.symlink(src, dest)); | ||
.then(() => link(src, dest)); | ||
}); | ||
}; |
@@ -33,13 +33,9 @@ 'use strict'; | ||
const data = fix(plist.parse(content)); | ||
data.version = pkg.version; | ||
data.description = pkg.description; | ||
data.name = pkg.name.replace(/^alfred\-/, ''); | ||
data.version = pkg.version || ''; | ||
data.description = pkg.description || ''; | ||
data.webaddress = pkg.homepage || pkg.author.url || ''; | ||
data.createdby = pkg.author.name || ''; | ||
if (pkg.author && typeof pkg.author === 'object') { | ||
data.createdby = pkg.author.name; | ||
data.webaddress = pkg.author.url; | ||
} | ||
return fsP.writeFile(file, plist.build(data)); | ||
}); | ||
}; |
{ | ||
"name": "alfred-link", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Make your Alfred workflows installable from npm", | ||
@@ -43,4 +43,4 @@ "license": "MIT", | ||
"pify": "^2.3.0", | ||
"pkg-up": "^1.0.0", | ||
"plist": "^2.0.1", | ||
"read-pkg-up": "^1.0.1", | ||
"resolve-alfred-prefs": "^1.0.0" | ||
@@ -47,0 +47,0 @@ }, |
@@ -41,11 +41,17 @@ # alfred-link [![Build Status](https://travis-ci.org/SamVerschueren/alfred-link.svg?branch=master)](https://travis-ci.org/SamVerschueren/alfred-link) | ||
|-------------|--------------| | ||
| name | name | | ||
| version | version | | ||
| description | description | | ||
| webaddress | homepage | | ||
| createdby | author.name | | ||
| webaddress | author.url | | ||
> Note: If the workflow is prefixed by `alfred-`, that prefix is being removed in the name of `info.plist`. For example, `alfred-unicorn` becomes `unicorn`. | ||
## Development | ||
When developing an Alfred workflow, you can call `alfred-link` directly from your cli. Either by installing `alfred-link` globally or by calling `alfred-link` from your `node_modules/.bin` directory. This will create a symlink in the Alfred workflows directory pointing to your development location without transforming `info.plist`. | ||
``` | ||
$ ./node_modules/.bin/alfred-link | ||
``` | ||
## Related | ||
@@ -52,0 +58,0 @@ |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
6505
7
88
64
4
+ Addedread-pkg-up@^1.0.1
+ Addederror-ex@1.3.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhosted-git-info@2.8.9(transitive)
+ Addedis-arrayish@0.2.1(transitive)
+ Addedis-core-module@2.13.1(transitive)
+ Addedis-utf8@0.2.1(transitive)
+ Addedload-json-file@1.1.0(transitive)
+ Addednormalize-package-data@2.5.0(transitive)
+ Addedparse-json@2.2.0(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpath-type@1.1.0(transitive)
+ Addedread-pkg@1.1.0(transitive)
+ Addedread-pkg-up@1.0.1(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedspdx-correct@3.2.0(transitive)
+ Addedspdx-exceptions@2.5.0(transitive)
+ Addedspdx-expression-parse@3.0.1(transitive)
+ Addedspdx-license-ids@3.0.18(transitive)
+ Addedstrip-bom@2.0.0(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedvalidate-npm-package-license@3.0.4(transitive)
- Removedpkg-up@^1.0.0
- Removedpkg-up@1.0.0(transitive)