├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── bin └── index ├── lib └── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | node 29 | 30 | tmp 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Urucas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | BABEL = ./node_modules/.bin/babel 3 | 4 | all: node 5 | 6 | node: lib 7 | @mkdir -p node/ 8 | @for path in lib/*.js; do \ 9 | file=`basename $$path`; \ 10 | $(BABEL) "lib/$$file" > "node/$$file"; \ 11 | done 12 | 13 | clean: 14 | @rm -rf ./node/ 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # node-osx-scanner 2 | Scanning an image in osx from Node 3 | 4 | # Install 5 | ```bash 6 | npm install --save node-osx-scanner 7 | ``` 8 | 9 | # Usage 10 | ```javascript 11 | var scan = require("node-osx-scanner"); 12 | var response = scan(); 13 | console.log(response); 14 | // {state:"Finished", imagePath:"./tmp/14338224024.jpeg"} 15 | ``` 16 | 17 | # Options 18 | Scan params: 19 | 20 | * **tmpFolder** : temporary folder of scanned images 21 | * **verbose** : [true|false] log osx-scanner stdout 22 | 23 | 24 | # Related 25 | [osx-scanner](https://github.com/Urucas/osx-scanner) - Scanning in osx from command-line 26 | -------------------------------------------------------------------------------- /bin/index: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var scan = require('../node/'); 3 | var response = scan(); 4 | console.log(response); 5 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | // es6 runtime requirements 2 | require('babel/polyfill'); 3 | import child_process from 'child_process'; 4 | import fs from 'fs'; 5 | 6 | export default function scan({ 7 | tmpFolder = "./tmp", 8 | verbose = false 9 | } = {}){ 10 | // run native osx-scanner 11 | let process = __dirname + "/../node_modules/osx-scanner/osx-scanner/osx-scanner"; 12 | let child = child_process.spawnSync(process, []); 13 | 14 | // parse response 15 | let output = " " + child.stdout.toString(); 16 | output = output.split("\n"); 17 | 18 | let response = {}; 19 | for(let i=0;i", 30 | "license": "MIT", 31 | "bugs": { 32 | "url": "https://github.com/Urucas/node-osx-scanner/issues" 33 | }, 34 | "homepage": "https://github.com/Urucas/node-osx-scanner", 35 | "dependencies": { 36 | "babel": "^5.5.5", 37 | "osx-scanner": "0.0.2" 38 | } 39 | } 40 | --------------------------------------------------------------------------------