forked from Penneo/ipp-printer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbin.js
More file actions
executable file
·25 lines (20 loc) · 692 Bytes
/
bin.js
File metadata and controls
executable file
·25 lines (20 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env node
'use strict'
var config = require('rc')('ipp-printer', {
name: 'ipp-printer', dir: process.cwd(), port: 3000
})
var nonPrivate = require('non-private-ip')
var url = require('url')
var ip = nonPrivate() || nonPrivate.private()
var fs = require('fs')
var Printer = require('./')
var p = new Printer(config)
p.on('job', function (job) {
var filename = 'printjob-' + job.id + '-' + Date.now() + '.ps'
job.pipe(fs.createWriteStream(filename)).on('finish', function () {
console.log('printed:', filename)
})
})
p.server.on('listening', function () {
console.log('ipp-printer listening on:', url.format({protocol: 'http', hostname: ip, port: config.port}))
})