start npm! data-files package

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-12-19 00:00:01 +00:00
parent 7c6454e5c1
commit 7c4a688187
10 changed files with 62 additions and 1 deletions

3
.gitignore vendored
View File

@@ -37,3 +37,6 @@ __pycache__
.tmp_versions
Module.symvers
modules.order
# node.js
node_modules

View File

@@ -14411,7 +14411,9 @@ Examples:
==== Node.js
Build and install the interpreter with:
Host installation shown at: https://askubuntu.com/questions/594656/how-to-install-the-latest-versions-of-nodejs-and-npm/971612#971612
Build and install the interpreter in Buildroot with:
....
./build-buildroot --config 'BR2_PACKAGE_NODEJS=y'
@@ -14436,6 +14438,26 @@ Examples:
** link:rootfs_overlay/lkmc/nodejs/file_write_read.js[]
** link:rootfs_overlay/lkmc/nodejs/read_stdin_to_string.js[] Question: https://stackoverflow.com/questions/30441025/read-all-text-from-stdin-to-a-string
===== NPM
https://en.wikipedia.org/wiki/Npm_(software)
Some sample packages can be found under: link:npm[].
Local testing of those packages can be done as shown at: https://stackoverflow.com/questions/59389027/how-to-interactively-test-the-executable-of-an-npm-node-js-package-during-develo
The packages will also be published to the NPM registry, so you can also play with them as:
....
npm install cirosantilli-<directory-name>
....
====== NPM data-files
Illustrates how to add extra non-code data files to an NPM package, and then use those files at runtime:
https://stackoverflow.com/questions/10111163/in-node-js-how-can-i-get-the-path-of-a-module-i-have-loaded-via-require-that-is
==== Java
No OpenJDK package as of 2018.08: https://stackoverflow.com/questions/28874150/buildroot-with-jamvm-2-0-for-java-8/59290927#59290927 partly because their build system is shit like the rest of the project's setup.

1
npm/README.adoc Normal file
View File

@@ -0,0 +1 @@
https://cirosantilli.com/linux-kernel-module-cheat#npm

1
npm/data-files/.nvmrc Normal file
View File

@@ -0,0 +1 @@
v10.15.1

View File

@@ -0,0 +1 @@
https://cirosantilli.com/linux-kernel-module-cheat#npm-data-files

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env node
const cirosantilli_data_files = require('cirosantilli-data-files');
console.log(cirosantilli_data_files.myfunc());

8
npm/data-files/index.js Normal file
View File

@@ -0,0 +1,8 @@
const fs = require('fs');
const path = require('path');
function myfunc() {
const package_path = path.dirname(require.resolve(path.join('cirosantilli-data-files', 'package.json')));
return fs.readFileSync(path.join(package_path, 'mydata.txt'), 'utf-8');
}
exports.myfunc = myfunc;

View File

@@ -0,0 +1 @@
hello world

5
npm/data-files/package-lock.json generated Normal file
View File

@@ -0,0 +1,5 @@
{
"name": "cirosantilli-data-files",
"version": "0.1.0",
"lockfileVersion": 1
}

View File

@@ -0,0 +1,14 @@
{
"bin": {
"cirosantilli-data-files": "cirosantilli-data-files"
},
"license": "MIT",
"files": [
"cirosantilli-data-files",
"mydata.txt",
"index.js"
],
"name": "cirosantilli-data-files",
"repository": "cirosantilli/linux-kernel-module-cheat",
"version": "0.1.0"
}