* Split core lib into multiple files * Refactor data encoding methods * Refactor data masking process * Improve qr code generation process * Increase minimum required node version to 0.10 * Add linter * Add tests and tests coverage * Update travis config to fix compilation issues * Add examples folder * Add missing license tag in package.json * Update build script and add sourcemap support * Publish only strictly needed files on npm * Update readme
34 lines
806 B
JavaScript
Executable file
34 lines
806 B
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
try {
|
|
var qr = require('../lib')
|
|
} catch (e) {
|
|
qr = require('qrcode')
|
|
}
|
|
|
|
var text = process.argv[2]
|
|
var file = process.argv[3]
|
|
|
|
if (text && text.length) {
|
|
if (file && file.length) {
|
|
qr.save(file, text, function (err, data) {
|
|
if (!err) {
|
|
process.stdout.write('saved qrcode to: ' + file + '\n')
|
|
} else {
|
|
process.stderr.write('failed to save qrcode\n')
|
|
throw err
|
|
}
|
|
})
|
|
} else {
|
|
qr.drawText(text, function (error, text) {
|
|
if (error) {
|
|
throw new Error(error)
|
|
}
|
|
|
|
process.stdout.write(text)
|
|
process.stdout.write('\n')
|
|
})
|
|
}
|
|
} else {
|
|
process.stderr.write('text\n\trequired as first argument.\nfile name [optional]\n\tto save png or svg qrcode may be provided as optional second argument\n')
|
|
}
|