From 7c4a6881873b54c572c7c77d4f2fca9f66fc62be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Thu, 19 Dec 2019 00:00:01 +0000 Subject: [PATCH] start npm! data-files package --- .gitignore | 3 +++ README.adoc | 24 +++++++++++++++++++++++- npm/README.adoc | 1 + npm/data-files/.nvmrc | 1 + npm/data-files/README.adoc | 1 + npm/data-files/cirosantilli-data-files | 5 +++++ npm/data-files/index.js | 8 ++++++++ npm/data-files/mydata.txt | 1 + npm/data-files/package-lock.json | 5 +++++ npm/data-files/package.json | 14 ++++++++++++++ 10 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 npm/README.adoc create mode 100644 npm/data-files/.nvmrc create mode 100644 npm/data-files/README.adoc create mode 100755 npm/data-files/cirosantilli-data-files create mode 100644 npm/data-files/index.js create mode 100644 npm/data-files/mydata.txt create mode 100644 npm/data-files/package-lock.json create mode 100644 npm/data-files/package.json diff --git a/.gitignore b/.gitignore index 717eb68..ec4bc4e 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,6 @@ __pycache__ .tmp_versions Module.symvers modules.order + +# node.js +node_modules diff --git a/README.adoc b/README.adoc index 18ae2e6..067a87e 100644 --- a/README.adoc +++ b/README.adoc @@ -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- +.... + +====== 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. diff --git a/npm/README.adoc b/npm/README.adoc new file mode 100644 index 0000000..d1b7209 --- /dev/null +++ b/npm/README.adoc @@ -0,0 +1 @@ +https://cirosantilli.com/linux-kernel-module-cheat#npm diff --git a/npm/data-files/.nvmrc b/npm/data-files/.nvmrc new file mode 100644 index 0000000..70324da --- /dev/null +++ b/npm/data-files/.nvmrc @@ -0,0 +1 @@ +v10.15.1 diff --git a/npm/data-files/README.adoc b/npm/data-files/README.adoc new file mode 100644 index 0000000..cd16559 --- /dev/null +++ b/npm/data-files/README.adoc @@ -0,0 +1 @@ +https://cirosantilli.com/linux-kernel-module-cheat#npm-data-files diff --git a/npm/data-files/cirosantilli-data-files b/npm/data-files/cirosantilli-data-files new file mode 100755 index 0000000..b25ebd9 --- /dev/null +++ b/npm/data-files/cirosantilli-data-files @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +const cirosantilli_data_files = require('cirosantilli-data-files'); + +console.log(cirosantilli_data_files.myfunc()); diff --git a/npm/data-files/index.js b/npm/data-files/index.js new file mode 100644 index 0000000..adcb404 --- /dev/null +++ b/npm/data-files/index.js @@ -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; diff --git a/npm/data-files/mydata.txt b/npm/data-files/mydata.txt new file mode 100644 index 0000000..3b18e51 --- /dev/null +++ b/npm/data-files/mydata.txt @@ -0,0 +1 @@ +hello world diff --git a/npm/data-files/package-lock.json b/npm/data-files/package-lock.json new file mode 100644 index 0000000..831a18d --- /dev/null +++ b/npm/data-files/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "cirosantilli-data-files", + "version": "0.1.0", + "lockfileVersion": 1 +} diff --git a/npm/data-files/package.json b/npm/data-files/package.json new file mode 100644 index 0000000..09555a1 --- /dev/null +++ b/npm/data-files/package.json @@ -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" +}