Skip to content

Commit

Permalink
fix: publication-script for the node-record-test executable (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Apr 27, 2021
1 parent 7cfa78a commit e4a8071
Show file tree
Hide file tree
Showing 4 changed files with 725 additions and 58 deletions.
5 changes: 4 additions & 1 deletion packages/node-record-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@xkeys/record-test",
"version": "2.0.0",
"private": true,
"description": "A script for recording tests",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down Expand Up @@ -46,7 +47,9 @@
"tslib": "^2.1.0"
},
"optionalDependencies": {
"usb-detection": "^4.10.0"
"usb-detection": "^4.10.0",
"nexe": "^3.3.7",
"find": "^0.3.0"
},
"keywords": [
"xkeys",
Expand Down
45 changes: 45 additions & 0 deletions packages/node-record-test/scripts/copy-natives.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const find = require('find');
const os = require('os')
const path = require('path')
const fs = require('fs-extra')

const arch = os.arch()
const platform = os.platform()
const prebuildType = process.argv[2] || `${platform}-${arch}`

// function isFileForPlatform(filename) {
// if (filename.indexOf(path.join('prebuilds', prebuildType)) !== -1) {
// return true
// } else {
// return false
// }
// }

const sourceDirName = path.join(__dirname, '../../../')
// const targetDirName = path.join(__dirname, '../')

console.log('Copy-Natives --------------')
console.log('Looking for modules in', sourceDirName, 'for', prebuildType)
// console.log('to copy into ', targetDirName)

const modulesToCopy = new Map()
find.file(/\.node$/, path.join(sourceDirName, 'node_modules'), (files) => {
files.forEach(fullPath => {
console.log(fullPath)
if (fullPath.indexOf(sourceDirName) === 0) {
console.log('a')
const file = fullPath.substr(sourceDirName.length)

const moduleName = file.match(/node_modules[\/\\]([^\\\/]+)/)
if (moduleName) {
modulesToCopy.set(moduleName[1], true)
}
}
})

modulesToCopy.forEach((_, moduleName) => {
console.log('copying', moduleName)

fs.copySync(path.join(sourceDirName, 'node_modules', moduleName) , path.join('deploy/node_modules/', moduleName ))
})
})
43 changes: 0 additions & 43 deletions scripts/copy-natives.js

This file was deleted.

Loading

0 comments on commit e4a8071

Please sign in to comment.