This repository has been archived by the owner on Sep 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 150
如何打包成可执行文件
Srar edited this page Jul 18, 2019
·
4 revisions
- 安装Visual C++构建环境
- 选项1: 使用Visual C++ Build Tools默认安装.
- 选项2: 安装带有Visual C++环境的Visual Studio 2017.
- 安装Python2
更多信息请参考https://github.com/nodejs/node-gyp#on-windows
git clone https://github.com/Srar/node-tap.git
cd ./node-tap
npm install --unsafe
'use strict';
/*
* @api public
* @property {function} format
* Both the construction method and set of exposed
* formats.
*/
const format = exports.format = require('./format');
/*
* @api public
* @method {function} levels
* Registers the specified levels with logform.
*/
exports.levels = require('./levels');
const formats = {
align: require("./align.js"),
errors: require("./errors.js"),
cli: require("./cli.js"),
combine: require("./combine.js"),
colorize: require("./colorize.js"),
json: require("./json.js"),
label: require("./label.js"),
logstash: require("./logstash.js"),
metadata: require("./metadata.js"),
ms: require("./ms.js"),
padLevels: require("./pad-levels.js"),
prettyPrint: require("./pretty-print.js"),
printf: require("./printf.js"),
simple: require("./simple.js"),
splat: require("./splat.js"),
timestamp: require("./timestamp.js"),
uncolorize: require("./uncolorize.js")
};
/*
* @api private
* method {function} exposeFormat
* Exposes a sub-format on the main format object
* as a lazy-loaded getter.
*/
function exposeFormat(name, path) {
path = path || name;
Object.defineProperty(format, name, {
get() {
return formats[name];
},
configurable: true
});
}
//
// Setup all transports as lazy-loaded getters.
//
exposeFormat('align');
exposeFormat('errors');
exposeFormat('cli');
exposeFormat('combine');
exposeFormat('colorize');
exposeFormat('json');
exposeFormat('label');
exposeFormat('logstash');
exposeFormat('metadata');
exposeFormat('ms');
exposeFormat('padLevels', 'pad-levels');
exposeFormat('prettyPrint', 'pretty-print');
exposeFormat('printf');
exposeFormat('simple');
exposeFormat('splat');
exposeFormat('timestamp');
exposeFormat('uncolorize');
# TypeScript转换为JavaScript
npm run build
# 编译native库
npm run compile
# 打包成可执行文件
npm run package
当执行完毕以上命令且没有错误时, 您应当会在目录下找到一个名为sstap.exe
的可执行文件.
您还需要将以下文件或目录放置在sstap.exe
同一个目录.
-
\node-tap\
下的driver
目录以及目录内文件. -
\node-tap\build\Release\
下的addon.node
文件. -
\node-tap\
下的node_modules
目录. -
\node-tap\node_modules\
下的cap
目录以及目录内文件. -
\node-tap\node_modules\
下的raw-socket
目录以及目录内文件.
结构
node-tap\
├── node_modules\
│ ├── cap\
│ └── ....
│ ├── raw-socket\
│ └── ....
│ ├── driver\
│ └── ....
├── sstap.exe
└── addon.node
此时不出意外的话您就已经完成了打包操作.