Last active
November 19, 2019 15:17
-
-
Save HipsterBrown/ade406d42b07165663b416a48cdc2839 to your computer and use it in GitHub Desktop.
Minimal nw.js app using node-serialport
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules/ | |
dist/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build_from_source=true | |
runtime=node-webkit | |
target=0.28.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Serialport Test</title> | |
</head> | |
<body> | |
<h1>Testing out serialport</h1> | |
<script src="./dist/app.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { get } from 'lodash'; | |
const Serialport = window.require('serialport'); | |
Serialport.list() | |
.then(ports => { | |
ports.forEach(p => console.log(get(p, 'comName'))); | |
}) | |
.catch(console.error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "nw-serialport", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.html", | |
"scripts": { | |
"build": "webpack" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"lodash": "^4.17.11", | |
"serialport": "^7.0.2" | |
}, | |
"devDependencies": { | |
"webpack": "^4.23.1", | |
"webpack-cli": "^3.1.2" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
mode: 'development', | |
entry: './index.js', | |
output: { | |
filename: 'app.js', | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment