This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
a3f9110
commit 3941c7d
Showing
6 changed files
with
169 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
lib-es5 | ||
node_modules | ||
dist |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package-lock.json | ||
node_modules |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
/* eslint-disable no-unused-vars */ | ||
var canvas = require('canvas'); | ||
console.log('42'); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
const utils = require('../utils.js'); | ||
|
||
assert(__dirname === process.cwd()); | ||
|
||
/* only run on host */ | ||
if (process.argv[2] && process.argv[2] !== 'host') { | ||
console.log('skipped test'); | ||
return; | ||
} | ||
const target = /* process.argv[2] || */ 'host'; | ||
const input = './package.json'; | ||
const output = path.join( | ||
__dirname, | ||
'./test-output' + (process.platform === 'win32' ? '.exe' : '') | ||
); | ||
|
||
console.log('target = ', target); | ||
|
||
// remove any possible left-over | ||
utils.vacuum.sync('./node_modules'); | ||
|
||
const version = utils.exec.sync('node --version'); | ||
console.log('node version = ', version); | ||
|
||
// launch `npm install` | ||
const npmlog = utils.exec.sync('npm install'); | ||
console.log('npm log :', npmlog); | ||
|
||
// verify that we have the .pnpm folder and a symlinks module in node_modules | ||
assert(fs.lstatSync(path.join(__dirname, 'node_modules/canvas')).isDirectory()); | ||
assert( | ||
fs.lstatSync(path.join(__dirname, 'node_modules/canvas/build')).isDirectory() | ||
); | ||
assert( | ||
fs | ||
.lstatSync(path.join(__dirname, 'node_modules/canvas/build/Release')) | ||
.isDirectory() | ||
); | ||
assert( | ||
fs | ||
.lstatSync( | ||
path.join(__dirname, 'node_modules/canvas/build/Release/canvas.node') | ||
) | ||
.isFile() | ||
); | ||
|
||
utils.pkg.sync(['--target', target, '--debug', '--output', output, input]); | ||
|
||
// check that produced executable is running and produce the expected output. | ||
const log = utils.spawn.sync(output, [], { | ||
cwd: path.dirname(output), | ||
expect: 0, | ||
}); | ||
console.log(log); | ||
// assert(log === '42\n'); | ||
|
||
// clean up | ||
utils.vacuum.sync(output); | ||
utils.vacuum.sync('./node_modules'); | ||
utils.vacuum.sync('./package-lock.json'); | ||
|
||
console.log('OK'); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "pkg_issue_1135", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"bin": "./index.js", | ||
"scripts": { | ||
"pkg": "npx pkg -t host package.json" | ||
}, | ||
"pkg": { | ||
"scripts": "index.js", | ||
"outputPath": "dist", | ||
"assets": "./node_modules/canvas/build/Release/*" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"canvas": "^2.7.0" | ||
} | ||
} |