node-print: new ptrcport
This commit is contained in:
parent
891ad0da45
commit
aa4b5eadb7
3 changed files with 48 additions and 0 deletions
27
node-print/APKBUILD
Normal file
27
node-print/APKBUILD
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
|
||||||
|
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
|
||||||
|
pkgname=node-print
|
||||||
|
pkgver=1
|
||||||
|
pkgrel=0
|
||||||
|
pkgdesc="another terrible javascript engine wrapper"
|
||||||
|
url="https://git.ddd.rip/ptrcnull/ptrcports"
|
||||||
|
arch="noarch"
|
||||||
|
license="BSD-2-Clause"
|
||||||
|
depends="nodejs-current"
|
||||||
|
source="np index.js"
|
||||||
|
builddir="$srcdir"
|
||||||
|
|
||||||
|
check() {
|
||||||
|
out="$(echo test | node -r . -p "stdin().substring(2).replace('t', 'rc').replace('s', 'pt')")"
|
||||||
|
[ "$out" == "ptrc" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
install -Dm755 np "$pkgdir"/usr/bin/np
|
||||||
|
install -Dm644 index.js "$pkgdir"/usr/lib/node/ptrc/index.js
|
||||||
|
}
|
||||||
|
|
||||||
|
sha512sums="
|
||||||
|
b3dfdeb49637be33d2e2718c5abcf35a87dd55023918c99341273c3b38bd6685189d1f786451a742c47c5f3bc3b58555decb58e2a3a018c9b9ee92043f8fac03 np
|
||||||
|
979cf7427821309c3f0a5e00d2ebac44d88582f949ddb71959a81a5ca8f4aca15f54a376c8217a94f7ab5aca229dddc59bcebb657ee0c319a5ace330750a8ddd index.js
|
||||||
|
"
|
18
node-print/index.js
Normal file
18
node-print/index.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
global.stdin = () => {
|
||||||
|
const fs = require('fs')
|
||||||
|
const out = fs.readFileSync(0).toString()
|
||||||
|
if (out.at(0) === '{') {
|
||||||
|
return JSON.parse(out)
|
||||||
|
} else {
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.prototype.map = function(cb) {
|
||||||
|
return cb(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
String.prototype.lines = function() {
|
||||||
|
let res = this.split("\n")
|
||||||
|
return res.at(-1) === '' ? res.slice(0, -1) : res
|
||||||
|
}
|
3
node-print/np
Normal file
3
node-print/np
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
exec node -r ptrc -p "$@"
|
Loading…
Reference in a new issue