mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-16 08:01:53 +00:00
add node-getmac modules
This commit is contained in:
7
node_modules/node-getmac/.npmignore
generated
vendored
Normal file
7
node_modules/node-getmac/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
.DS_Store
|
||||||
|
node_modules
|
||||||
|
*.log
|
||||||
|
test
|
||||||
|
coverage
|
||||||
|
out
|
||||||
|
output
|
7
node_modules/node-getmac/README.md
generated
vendored
Normal file
7
node_modules/node-getmac/README.md
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
get local mac in nodejs
|
||||||
|
|
||||||
|
### use
|
||||||
|
``` javascript
|
||||||
|
var macAddr = require('node-getmac');
|
||||||
|
|
||||||
|
// '60:03:08:98:a7:d8'
|
36
node_modules/node-getmac/index.js
generated
vendored
Normal file
36
node_modules/node-getmac/index.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* @file get local mac address
|
||||||
|
* @author liulangyu(liulangyu90316@gmail.com)
|
||||||
|
*/
|
||||||
|
|
||||||
|
var execSync = require('child_process').execSync;
|
||||||
|
var platform = process.platform;
|
||||||
|
|
||||||
|
module.exports = (function () {
|
||||||
|
var cmd = {
|
||||||
|
win32: 'getmac',
|
||||||
|
darwin: 'ifconfig -a',
|
||||||
|
linux: 'ifconfig -a || ip link'
|
||||||
|
}[platform];
|
||||||
|
|
||||||
|
var regStr = '((?:[a-z0-9]{2}[:-]){5}[a-z0-9]{2})';
|
||||||
|
|
||||||
|
var macReg = new RegExp('ether\\s' + regStr + '\\s', 'i');
|
||||||
|
|
||||||
|
try {
|
||||||
|
var data = execSync(cmd).toString();
|
||||||
|
var res = {
|
||||||
|
win32: new RegExp(regStr, 'i').exec(data),
|
||||||
|
darwin: macReg.exec(data),
|
||||||
|
linux: macReg.exec(data)
|
||||||
|
}[platform];
|
||||||
|
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
return res[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
})();
|
80
node_modules/node-getmac/package.json
generated
vendored
Normal file
80
node_modules/node-getmac/package.json
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
{
|
||||||
|
"_args": [
|
||||||
|
[
|
||||||
|
"node-getmac",
|
||||||
|
"/Users/life/Documents/kuaipan/leanote/desktop-app"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"_from": "node-getmac@latest",
|
||||||
|
"_id": "node-getmac@1.0.3",
|
||||||
|
"_inCache": true,
|
||||||
|
"_installable": true,
|
||||||
|
"_location": "/node-getmac",
|
||||||
|
"_nodeVersion": "8.4.0",
|
||||||
|
"_npmOperationalInternal": {
|
||||||
|
"host": "s3://npm-registry-packages",
|
||||||
|
"tmp": "tmp/node-getmac-1.0.3.tgz_1506680192636_0.27925579715520144"
|
||||||
|
},
|
||||||
|
"_npmUser": {
|
||||||
|
"email": "liulangyu90316@gmail.com",
|
||||||
|
"name": "liulangyu316"
|
||||||
|
},
|
||||||
|
"_npmVersion": "5.3.0",
|
||||||
|
"_phantomChildren": {},
|
||||||
|
"_requested": {
|
||||||
|
"name": "node-getmac",
|
||||||
|
"raw": "node-getmac",
|
||||||
|
"rawSpec": "",
|
||||||
|
"scope": null,
|
||||||
|
"spec": "latest",
|
||||||
|
"type": "tag"
|
||||||
|
},
|
||||||
|
"_requiredBy": [
|
||||||
|
"#USER"
|
||||||
|
],
|
||||||
|
"_resolved": "https://registry.npmjs.org/node-getmac/-/node-getmac-1.0.3.tgz",
|
||||||
|
"_shasum": "d2aa25e40fae11762302381b030d58b0e37d686a",
|
||||||
|
"_shrinkwrap": null,
|
||||||
|
"_spec": "node-getmac",
|
||||||
|
"_where": "/Users/life/Documents/kuaipan/leanote/desktop-app",
|
||||||
|
"author": {
|
||||||
|
"name": "liulangyu"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/michaelliu90316/node-getmac/issues"
|
||||||
|
},
|
||||||
|
"dependencies": {},
|
||||||
|
"description": "get local mac address. simple and work fine for mac linux and windows.",
|
||||||
|
"devDependencies": {},
|
||||||
|
"directories": {},
|
||||||
|
"dist": {
|
||||||
|
"integrity": "sha512-HEmIX5vFfYgpAH/MHiKgx4g7gCHWkBlmH+8huPk1d2cj73yKAdwcXqEykLpEzcRzIAUrAvd0sZhM/UKURS4xZA==",
|
||||||
|
"shasum": "d2aa25e40fae11762302381b030d58b0e37d686a",
|
||||||
|
"tarball": "https://registry.npmjs.org/node-getmac/-/node-getmac-1.0.3.tgz"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/michaelliu90316/node-getmac#readme",
|
||||||
|
"keywords": [
|
||||||
|
"node-mac",
|
||||||
|
"mac-address",
|
||||||
|
"windows-mac-linux"
|
||||||
|
],
|
||||||
|
"license": "ISC",
|
||||||
|
"main": "index.js",
|
||||||
|
"maintainers": [
|
||||||
|
{
|
||||||
|
"email": "liulangyu90316@gmail.com",
|
||||||
|
"name": "liulangyu316"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "node-getmac",
|
||||||
|
"optionalDependencies": {},
|
||||||
|
"readme": "ERROR: No README data found!",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/michaelliu90316/node-getmac.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "npm test"
|
||||||
|
},
|
||||||
|
"version": "1.0.3"
|
||||||
|
}
|
2
tests/test_getmac.js
Normal file
2
tests/test_getmac.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
var macAddr = require('node-getmac');
|
||||||
|
console.log(macAddr)
|
Reference in New Issue
Block a user