|
1 | 1 | const path = require('path')
|
2 |
| -const fs = require('fs') |
3 |
| -const { exec } = require('child_process') |
4 | 2 | const logger = require('@vue/cli-shared-utils')
|
5 | 3 | const webpack = require('webpack')
|
6 | 4 | const CopyWebpackPlugin = require('copy-webpack-plugin')
|
7 | 5 | const ExtensionReloader = require('webpack-extension-reloader')
|
8 | 6 | const ZipPlugin = require('zip-webpack-plugin')
|
| 7 | +const { keyExists, hashKey } = require('./lib/signing-key') |
9 | 8 | const defaultOptions = {
|
10 | 9 | components: {},
|
11 | 10 | componentOptions: {},
|
@@ -36,7 +35,7 @@ module.exports = (api, options) => {
|
36 | 35 | const packageJson = require(path.join(appRootPath, 'package.json'))
|
37 | 36 | const isProduction = api.service.mode === 'production'
|
38 | 37 | const keyFile = api.resolve('key.pem')
|
39 |
| - const hasKeyFile = fs.existsSync(keyFile) |
| 38 | + const hasKeyFile = keyExists(keyFile) |
40 | 39 |
|
41 | 40 | api.chainWebpack((webpackConfig) => {
|
42 | 41 | webpackConfig.entryPoints.delete('app')
|
@@ -114,15 +113,7 @@ module.exports = (api, options) => {
|
114 | 113 |
|
115 | 114 | if (hasKeyFile) {
|
116 | 115 | try {
|
117 |
| - jsonContent.key = await new Promise((resolve, reject) => { |
118 |
| - exec(`openssl rsa -in ${keyFile} -pubout -outform DER | openssl base64 -A`, (error, stdout) => { |
119 |
| - if (error) { |
120 |
| - // node couldn't execute the command |
121 |
| - return reject(error) |
122 |
| - } |
123 |
| - resolve(stdout) |
124 |
| - }) |
125 |
| - }) |
| 116 | + jsonContent.key = await hashKey(keyFile) |
126 | 117 | } catch (error) {
|
127 | 118 | logger.error('Unexpected error hashing keyfile:', error)
|
128 | 119 | }
|
|
0 commit comments