Repository: vercel/pkg Branch: main Commit: 9066ceeb391d Files: 1427 Total size: 1.2 MB Directory structure: gitextract_v7367qf3/ ├── .eslintignore ├── .eslintrc ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ ├── 01_bug_report.yml │ │ ├── 02_regression.yml │ │ └── config.yml │ └── workflows/ │ ├── ci.yml │ └── close-stale.yml ├── .gitignore ├── .prettierignore ├── .yarnrc ├── LICENSE ├── README.md ├── dictionary/ │ ├── .eslintrc.json │ ├── angular-bridge.js │ ├── any-promise.js │ ├── async.js │ ├── aws-sdk.js │ ├── babel-core.js │ ├── batch.js │ ├── bcrypt.js │ ├── better-sqlite3.js │ ├── bignum.js │ ├── bindings.js │ ├── blessed.js │ ├── body-parser.js │ ├── browserify.js │ ├── bson.js │ ├── buffermaker.js │ ├── bunyan.js │ ├── busboy.js │ ├── bytes.js │ ├── callsites.js │ ├── chokidar.js │ ├── coffee-script.js │ ├── colors.js │ ├── compression.js │ ├── compressjs.js │ ├── connect-mongo.js │ ├── connect-mongodb.js │ ├── connect-redis.js │ ├── connect.js │ ├── consolidate.js │ ├── cookie-parser.js │ ├── cookie.js │ ├── cors.js │ ├── cron.js │ ├── cross-env.js │ ├── cross-spawn-async.js │ ├── curve25519.js │ ├── data-preflight.js │ ├── debug.js │ ├── denymount.js │ ├── diff.js │ ├── drivelist.js │ ├── ed25519.js │ ├── ejs.js │ ├── elasticsearch.js │ ├── electron.js │ ├── emailjs.js │ ├── engine.io.js │ ├── epoll.js │ ├── errorhandler.js │ ├── errors.js │ ├── eslint.js │ ├── etcher-image-write.js │ ├── exceljs.js │ ├── exiftool.exe.js │ ├── exiftool.pl.js │ ├── express-load.js │ ├── express-session.js │ ├── express.js │ ├── extender.js │ ├── extsprintf.js │ ├── faye-websocket.js │ ├── feathers.js │ ├── findup-sync.js │ ├── floordate.js │ ├── fmt.js │ ├── formidable.js │ ├── fs-extra.js │ ├── fsevents.js │ ├── geoip-lite.js │ ├── github.js │ ├── gm.js │ ├── google-closure-compiler-java.js │ ├── google-closure-compiler.js │ ├── googleapis.js │ ├── got.js │ ├── graceful-fs.js │ ├── grpc.js │ ├── gulp.js │ ├── hap-nodejs.js │ ├── heapdump.js │ ├── hoek.js │ ├── homebridge.js │ ├── http-proxy.js │ ├── http-server.js │ ├── image-size.js │ ├── indexof.js │ ├── inquirer.js │ ├── j.js │ ├── jade.js │ ├── jsdom.js │ ├── json-stringify-date.js │ ├── json-stringify-safe.js │ ├── jsonwebtoken.js │ ├── kerberos.js │ ├── knex.js │ ├── later.js │ ├── level.js │ ├── leveldown.js │ ├── levelup.js │ ├── liftoff.js │ ├── lodash.js │ ├── log4js.js │ ├── logform.js │ ├── machinepack-urls.js │ ├── markdown.js │ ├── mdns.js │ ├── method-override.js │ ├── microjob.js │ ├── mime-types.js │ ├── mime.js │ ├── minimatch.js │ ├── minstache.js │ ├── module-deps.js │ ├── moment-timezone.js │ ├── moment.js │ ├── mongodb-core.js │ ├── mongodb.js │ ├── mongoose.js │ ├── mongoskin.js │ ├── ms.js │ ├── msgpack.js │ ├── multer.js │ ├── muri.js │ ├── native-or-bluebird.js │ ├── natives.js │ ├── nconf.js │ ├── nedb.js │ ├── negotiator.js │ ├── newrelic.js │ ├── nib.js │ ├── nightmare.js │ ├── node-forge.js │ ├── node-libcurl.js │ ├── node-notifier.js │ ├── node-pre-gyp.js │ ├── node-redis-pubsub.js │ ├── node-sass.js │ ├── node-uuid.js │ ├── node-xlsx.js │ ├── node-zookeeper-client.js │ ├── nodegit.js │ ├── nodemailer-sendmail-transport.js │ ├── nodemailer.js │ ├── npm-registry-client.js │ ├── npm.js │ ├── nssocket.js │ ├── oauth2orize.js │ ├── octobat.js │ ├── open.js │ ├── opn.js │ ├── optimist.js │ ├── passport-local.js │ ├── passport.js │ ├── pg-cursor.js │ ├── pg-query-stream.js │ ├── pg-types.js │ ├── pg.js │ ├── pg.js.js │ ├── pgpass.js │ ├── phantom.js │ ├── phantomjs-prebuilt.js │ ├── pkginfo.js │ ├── pm2.js │ ├── pmx.js │ ├── pouchdb.js │ ├── primus-emitter.js │ ├── primus-spark-latency.js │ ├── primus.js │ ├── publicsuffixlist.js │ ├── pug.js │ ├── punt.js │ ├── puppeteer.js │ ├── pwd.js │ ├── q.js │ ├── raven.js │ ├── rc.js │ ├── readable-stream.js │ ├── rechoir.js │ ├── redis-parser.js │ ├── redis.js │ ├── regression.js │ ├── reload.js │ ├── request.js │ ├── require-uncached.js │ ├── require_optional.js │ ├── s3.js │ ├── safe_datejs.js │ ├── sails.js │ ├── sax.js │ ├── scrypt.js │ ├── semver.js │ ├── sequelize.js │ ├── serialport.js │ ├── sha3.js │ ├── sharp.js │ ├── shelljs.js │ ├── sinon.js │ ├── socket.io-client.js │ ├── socket.io.js │ ├── sqip.js │ ├── sqlite3.js │ ├── steam-crypto.js │ ├── steam-resources.js │ ├── steam.js │ ├── stripe-webhook-middleware.js │ ├── stripe.js │ ├── strong-globalize.js │ ├── stylus.js │ ├── supervisor.js │ ├── svgo.js │ ├── tabtab.js │ ├── tesseract.js.js │ ├── throng.js │ ├── time.js │ ├── tinify.js │ ├── tiny-worker.js │ ├── tmp.js │ ├── transformers.js │ ├── uglify-js.js │ ├── umd.js │ ├── underscore.js │ ├── union.js │ ├── update-notifier.js │ ├── usage.js │ ├── v8flags.js │ ├── verror.js │ ├── voc.js │ ├── webdriverio.js │ ├── winston-uber.js │ ├── winston.js │ ├── ws.js │ ├── xlsx.js │ ├── xml2js.js │ ├── yargs.js │ └── zeromq.js ├── examples/ │ ├── .eslintrc.json │ └── express/ │ ├── index.js │ ├── package.json │ ├── readme.md │ └── views/ │ ├── index.html │ └── lib/ │ └── sakura.css ├── lib/ │ ├── bin.ts │ ├── chmod.ts │ ├── common.ts │ ├── compress_type.ts │ ├── detector.ts │ ├── fabricator.ts │ ├── follow.ts │ ├── help.ts │ ├── index.ts │ ├── log.js │ ├── mach-o.ts │ ├── packer.ts │ ├── producer.ts │ ├── refiner.ts │ ├── types.ts │ └── walker.ts ├── package.json ├── prelude/ │ ├── .eslintrc.json │ ├── bootstrap.js │ └── diagnostic.js ├── test/ │ ├── .eslintrc.json │ ├── .gitignore │ ├── test-42-fetch-all/ │ │ └── main.js │ ├── test-42-path-related-values/ │ │ ├── main.js │ │ └── project/ │ │ ├── app.js │ │ └── module.js │ ├── test-46-input/ │ │ ├── main.js │ │ └── test-x-index │ ├── test-46-input-js/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-output/ │ │ ├── main.js │ │ └── test-x-index │ ├── test-46-input-output-js/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-output-js-exe/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-output-target/ │ │ ├── main.js │ │ └── test-x-index │ ├── test-46-input-output-target-js/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-output-target-js-exe/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-output-targets-many/ │ │ ├── main.js │ │ └── test-x-index │ ├── test-46-input-output-targets-many-2/ │ │ ├── main.js │ │ └── test-x-index │ ├── test-46-input-output-targets-many-3/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-output-targets-many-4/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-output-targets-many-5/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-output-targets-many-6/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-package-json/ │ │ ├── main.js │ │ ├── package.json │ │ └── test-x-index.js │ ├── test-46-input-package-json-dir/ │ │ ├── main.js │ │ ├── package.json │ │ └── test-x-index.js │ ├── test-46-input-package-json-dir-scope/ │ │ ├── main.js │ │ ├── package.json │ │ └── test-x-index.js │ ├── test-46-input-package-json-outputdir/ │ │ ├── main.js │ │ ├── package.json │ │ └── test-x-index.js │ ├── test-46-input-package-json-target/ │ │ ├── main.js │ │ ├── package.json │ │ └── test-x-index.js │ ├── test-46-input-target/ │ │ ├── main.js │ │ └── test-x-index │ ├── test-46-input-target-js/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-target-js-exe/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-targets-many/ │ │ ├── main.js │ │ └── test-x-index │ ├── test-46-input-targets-many-2/ │ │ ├── main.js │ │ └── test-x-index │ ├── test-46-input-targets-many-3/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-targets-many-4/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-targets-many-5/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-input-targets-many-6/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-multi-arch/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-multi-arch-2/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-46-outpath/ │ │ ├── main.js │ │ └── test-x-index │ ├── test-46-outpath-target/ │ │ ├── main.js │ │ └── test-x-index │ ├── test-46-outpath-targets-many/ │ │ ├── main.js │ │ └── test-x-index │ ├── test-48-common/ │ │ └── main.js │ ├── test-50-api/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-arguments/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-ast-parsing/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ └── test-y-data.txt │ ├── test-50-ast-parsing-2/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-bakery/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-bakery-2/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-bakery-3/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-bakery-4/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-bakery-fetch/ │ │ └── main.js │ ├── test-50-can-include-addon/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ └── time.node │ ├── test-50-cannot-css-script/ │ │ ├── assets/ │ │ │ └── animate.css │ │ ├── main.js │ │ ├── package.json │ │ └── test-x-index.js │ ├── test-50-cannot-include-df/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-chdir-env-var/ │ │ ├── main.js │ │ └── source/ │ │ └── test-x-index.js │ ├── test-50-class-to-string/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-config-log/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-console-trace/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-corrupt-executable/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-debug/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-error-source-position/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-extensions/ │ │ ├── .eslintrc.json │ │ ├── main.js │ │ ├── test-x-index.js │ │ ├── test-y-esnext.js │ │ └── test-z-sub.js │ ├── test-50-for-await-of/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-fs-runtime-layer/ │ │ ├── main.js │ │ ├── package.json │ │ ├── test-x-index.js │ │ ├── test-x1-index.js │ │ ├── test-x2-index.js │ │ ├── test-x3-index.js │ │ ├── test-z-asset-A.css │ │ └── test-z-asset-B.css │ ├── test-50-fs-runtime-layer-2/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ └── test-z-asset.css │ ├── test-50-fs-runtime-layer-3/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ └── test-z-asset.css │ ├── test-50-global-object/ │ │ ├── main.js │ │ ├── package.json │ │ ├── test-x-index.js │ │ ├── test-y-resolve-A.js │ │ └── test-y-resolve-B.js │ ├── test-50-inspect/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-invalid/ │ │ └── main.js │ ├── test-50-invalid-package-json/ │ │ └── main.js │ ├── test-50-invalid-package-json-2/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-invalid-package-json-bin/ │ │ ├── main.js │ │ └── package.json │ ├── test-50-invalid-package-json-bin-2/ │ │ ├── main.js │ │ └── package.json │ ├── test-50-invalid-unknown-token/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-many-arrow-functions/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ └── test-z-creator.js │ ├── test-50-many-callbacks/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ └── test-z-creator.js │ ├── test-50-may-exclude/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-may-exclude-must-exclude/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ └── test-y-index.js │ ├── test-50-module-parent/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ ├── test-y-fish-A.js │ │ ├── test-y-fish-B.js │ │ └── test-y-fish-C.js │ ├── test-50-mountpoints/ │ │ ├── main.js │ │ ├── plugins-C-int/ │ │ │ └── test-y-require-C.js │ │ ├── plugins-D-ext/ │ │ │ └── test-y-require-D.js │ │ ├── test-x-index.js │ │ └── test-y-common.js │ ├── test-50-native-addon/ │ │ ├── lib/ │ │ │ └── time.node │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-native-addon-2/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-native-addon-3/ │ │ ├── lib/ │ │ │ ├── community/ │ │ │ │ ├── test-y-index.js │ │ │ │ └── time-y.node │ │ │ ├── enterprise/ │ │ │ │ ├── test-z-index.js │ │ │ │ └── time-z.node │ │ │ ├── test-x-index.js │ │ │ └── time-x.node │ │ └── main.js │ ├── test-50-native-addon-4/ │ │ ├── lib/ │ │ │ └── time.node │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-no-signature/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-no-super-in-constructor/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-node-modules-tree/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ ├── test-y-fish-A.js │ │ ├── test-y-fish-B.js │ │ ├── test-y-fish-E │ │ ├── test-y-fish-F │ │ ├── test-y-fish-G │ │ ├── test-y-fish-H │ │ ├── test-y-fish-I │ │ ├── test-y-fish-J │ │ ├── test-y-fish-M │ │ ├── test-y-fish-N │ │ ├── test-y-fish-O │ │ └── test-y-fish-P │ ├── test-50-non-ascii/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ └── test-y-$$.js │ ├── test-50-not-found-wording/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-not-found-wording-2/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-object-spread/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-observe-snapshot-root/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-observe-snapshot-root-2/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-odd-entrypoint/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-package-a-binary/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-package-json/ │ │ ├── main.js │ │ ├── package.json │ │ ├── test-x-index.js │ │ ├── test-y-resolve-A.js │ │ ├── test-y-resolve-B.txt │ │ └── test-y-resolve-C.json │ ├── test-50-package-json-2/ │ │ ├── main.js │ │ ├── package.json │ │ ├── sub/ │ │ │ └── test-x-index.js │ │ └── test-y-data.json │ ├── test-50-package-json-3/ │ │ ├── main.js │ │ ├── package.json │ │ ├── test-x-index.js │ │ └── test-y-data.json │ ├── test-50-package-json-4/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-package-json-5/ │ │ └── main.js │ ├── test-50-package-json-6/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-package-json-6b/ │ │ └── main.js │ ├── test-50-package-json-6c/ │ │ ├── beta/ │ │ │ ├── alpha.js │ │ │ ├── beta.js │ │ │ └── package.json │ │ └── main.js │ ├── test-50-package-json-6d/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-package-json-7/ │ │ ├── main.js │ │ ├── package.json │ │ └── test-x-index.js │ ├── test-50-package-json-7p/ │ │ ├── main.js │ │ ├── package.json │ │ └── test-x-index.js │ ├── test-50-package-json-8/ │ │ ├── main.js │ │ ├── package.json │ │ ├── sub/ │ │ │ ├── sub/ │ │ │ │ └── test-y-require.js │ │ │ ├── test-x-index.js │ │ │ └── test-z-require.js │ │ └── test-z-data.css │ ├── test-50-package-json-8b/ │ │ ├── main.js │ │ ├── package.json │ │ ├── sub/ │ │ │ ├── sub/ │ │ │ │ └── test-y-require.js │ │ │ ├── test-x-index.js │ │ │ └── test-z-require.js │ │ └── test-z-data.css │ ├── test-50-package-json-8p/ │ │ ├── main.js │ │ ├── package.json │ │ ├── sub/ │ │ │ ├── sub/ │ │ │ │ └── test-y-require.js │ │ │ ├── test-x-index.js │ │ │ └── test-z-require.js │ │ └── test-z-data.css │ ├── test-50-package-json-9/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-package-json-9p/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-package-json-A/ │ │ ├── main.js │ │ ├── package.json │ │ └── test-x-index.js │ ├── test-50-path-as-buffer/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ └── test-z-asset.css │ ├── test-50-path-separators/ │ │ ├── main.js │ │ ├── package.json │ │ ├── sub/ │ │ │ ├── test-y-require-C.js │ │ │ └── test-y-require-D.js │ │ └── test-x-index.js │ ├── test-50-promisify/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-public-packages/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-reproducible/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-require-edge-cases/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ ├── test-x1-content.js │ │ ├── test-x2-require-false.js │ │ └── test-x3-empty-file.js │ ├── test-50-require-main-parent/ │ │ ├── main.js │ │ ├── sub/ │ │ │ ├── test-y-require-C.js │ │ │ └── test-y-require-D.js │ │ ├── test-x-index.js │ │ ├── test-y-require-A.js │ │ └── test-y-require-B.js │ ├── test-50-require-resolve/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ ├── test-y-resolve.any │ │ ├── test-z-require-code-1.js │ │ ├── test-z-require-code-2.js │ │ ├── test-z-require-code-3.js │ │ ├── test-z-require-code-4.js │ │ ├── test-z-require-content.css │ │ ├── test-z-require-json-1.json │ │ ├── test-z-require-json-2.json │ │ ├── test-z-require-json-3.json │ │ ├── test-z-require-json-4.json │ │ └── test-z-require-json-5.json │ ├── test-50-require-resolve-2/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ ├── test-y-resolve-A.txt │ │ ├── test-y-resolve-B.txt │ │ ├── test-y-resolve-C.txt │ │ ├── test-y-resolve-D.txt │ │ ├── test-y-resolve-E.txt │ │ ├── test-y-resolve-F.txt │ │ ├── test-y-resolve-G.txt │ │ ├── test-y-resolve-H.txt │ │ ├── test-z-require-code-I.js │ │ ├── test-z-require-code-J.js │ │ ├── test-z-require-content-K.txt │ │ ├── test-z-require-content-L.txt │ │ ├── test-z-require-content-M.txt │ │ └── test-z-require-content-N.txt │ ├── test-50-require-with-config/ │ │ ├── main.js │ │ ├── package.json │ │ ├── test-x-index.js │ │ ├── test-y-resolve-A.txt │ │ ├── test-y-resolve-B.txt │ │ ├── test-y-resolve-C.txt │ │ ├── test-y-resolve-D.txt │ │ ├── test-y-resolve-E.txt │ │ ├── test-y-resolve-F.txt │ │ ├── test-y-resolve-G.txt │ │ ├── test-y-resolve-H.txt │ │ ├── test-z-require-code-I.js │ │ ├── test-z-require-code-J.js │ │ ├── test-z-require-content-K.txt │ │ ├── test-z-require-content-L.txt │ │ ├── test-z-require-content-M.txt │ │ └── test-z-require-content-N.txt │ ├── test-50-resolve-and-nearby/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ └── test-y-fish │ ├── test-50-should-disclose-package/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-signature/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-sigusr1/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-spawn/ │ │ ├── main.js │ │ ├── test-cluster-child.js │ │ ├── test-cluster.js │ │ ├── test-cpfork-a-1.js │ │ ├── test-cpfork-a-2.js │ │ ├── test-cpfork-a-child.js │ │ ├── test-cpfork-b-1.js │ │ ├── test-cpfork-b-2.js │ │ ├── test-cpfork-b-child.js │ │ ├── test-exec-1.js │ │ ├── test-exec-2.js │ │ ├── test-exec-3.js │ │ ├── test-exec-child.js │ │ ├── test-execFile-child.js │ │ ├── test-execFile.js │ │ ├── test-execFileSync-child.js │ │ ├── test-execFileSync.js │ │ ├── test-execSync-1.js │ │ ├── test-execSync-2.js │ │ ├── test-execSync-3.js │ │ ├── test-execSync-child.js │ │ ├── test-node.js │ │ ├── test-spawn-a-1.js │ │ ├── test-spawn-a-2.js │ │ ├── test-spawn-a-3.js │ │ ├── test-spawn-a-4.js │ │ ├── test-spawn-a-5.js │ │ ├── test-spawn-a-child.js │ │ ├── test-spawn-b-child.js │ │ ├── test-spawn-b.js │ │ ├── test-spawn-c-child.js │ │ ├── test-spawn-c.js │ │ ├── test-spawn-d-child.js │ │ ├── test-spawn-d.js │ │ ├── test-spawnSync-child.js │ │ └── test-spawnSync.js │ ├── test-50-symlink/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-tamper-core/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-50-undo-patch/ │ │ ├── main.js │ │ ├── test-x-index.js │ │ └── test-y-index.js │ ├── test-77-compare-dicts-and-tests/ │ │ └── main.js │ ├── test-78-verify-pkg-version/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-79-npm/ │ │ ├── angular-bridge/ │ │ │ ├── angular-bridge.js │ │ │ └── package.json │ │ ├── any-promise/ │ │ │ ├── any-promise.js │ │ │ ├── any-promise.meta.js │ │ │ └── package.json │ │ ├── async/ │ │ │ ├── async.js │ │ │ └── package.json │ │ ├── aws-sdk/ │ │ │ ├── aws-sdk.js │ │ │ └── package.json │ │ ├── babel-core/ │ │ │ ├── babel-core.js │ │ │ ├── babel-core.txt │ │ │ ├── babel-core@4.7.16.js │ │ │ └── package.json │ │ ├── batch/ │ │ │ ├── batch.js │ │ │ └── package.json │ │ ├── bcrypt/ │ │ │ ├── bcrypt.js │ │ │ └── package.json │ │ ├── better-sqlite3/ │ │ │ ├── .gitignore │ │ │ ├── better-sqlite3.js │ │ │ ├── better-sqlite3.meta.js │ │ │ └── package.json │ │ ├── bignum/ │ │ │ ├── bignum.js │ │ │ ├── bignum.meta.js │ │ │ └── package.json │ │ ├── bindings/ │ │ │ ├── bindings.js │ │ │ └── package.json │ │ ├── blessed/ │ │ │ ├── blessed.js │ │ │ └── package.json │ │ ├── body-parser/ │ │ │ ├── body-parser.js │ │ │ ├── body-parser@1.10.2.js │ │ │ └── package.json │ │ ├── browserify/ │ │ │ ├── browserify.js │ │ │ ├── browserify.meta.js │ │ │ └── package.json │ │ ├── bson/ │ │ │ ├── bson.js │ │ │ ├── bson@0.2.22.js │ │ │ ├── bson@0.2.22.meta.js │ │ │ ├── bson@0.4.0.js │ │ │ ├── bson@0.4.0.meta.js │ │ │ ├── bson@1.0.0.js │ │ │ └── package.json │ │ ├── buffermaker/ │ │ │ ├── buffermaker.js │ │ │ └── package.json │ │ ├── bunyan/ │ │ │ ├── bunyan.js │ │ │ └── package.json │ │ ├── busboy/ │ │ │ ├── busboy.js │ │ │ └── package.json │ │ ├── bytes/ │ │ │ ├── bytes.js │ │ │ ├── bytes@2.5.0.js │ │ │ └── package.json │ │ ├── callsites/ │ │ │ ├── callsites.js │ │ │ └── package.json │ │ ├── checklist.htm │ │ ├── checklist.js │ │ ├── chokidar/ │ │ │ ├── chokidar.js │ │ │ └── package.json │ │ ├── coffee-script/ │ │ │ ├── coffee-script-example.coffee │ │ │ ├── coffee-script.js │ │ │ └── package.json │ │ ├── colors/ │ │ │ ├── colors.js │ │ │ └── package.json │ │ ├── compression/ │ │ │ ├── compression.js │ │ │ └── package.json │ │ ├── compressjs/ │ │ │ ├── compressjs.js │ │ │ └── package.json │ │ ├── connect/ │ │ │ ├── connect.js │ │ │ ├── connect@2.3.9.js │ │ │ └── package.json │ │ ├── connect-mongo/ │ │ │ ├── connect-mongo.js │ │ │ ├── connect-mongo.meta.js │ │ │ ├── connect-mongo@0.8.2.js │ │ │ ├── connect-mongo@0.8.2.meta.js │ │ │ └── package.json │ │ ├── connect-mongodb/ │ │ │ ├── connect-mongodb.js │ │ │ ├── connect-mongodb.meta.js │ │ │ └── package.json │ │ ├── connect-redis/ │ │ │ ├── connect-redis.js │ │ │ ├── connect-redis.meta.js │ │ │ ├── connect-redis@2.5.1.js │ │ │ ├── connect-redis@2.5.1.meta.js │ │ │ └── package.json │ │ ├── consolidate/ │ │ │ ├── consolidate.js │ │ │ └── package.json │ │ ├── cookie/ │ │ │ ├── cookie.js │ │ │ └── package.json │ │ ├── cookie-parser/ │ │ │ ├── cookie-parser.js │ │ │ └── package.json │ │ ├── cors/ │ │ │ ├── cors.js │ │ │ └── package.json │ │ ├── cron/ │ │ │ ├── cron.js │ │ │ └── package.json │ │ ├── cross-env/ │ │ │ ├── cross-env.js │ │ │ └── package.json │ │ ├── cross-spawn-async/ │ │ │ ├── cross-spawn-async.js │ │ │ ├── fixture.js │ │ │ └── package.json │ │ ├── curve25519/ │ │ │ ├── package.json │ │ │ └── see.hap-nodejs.meta.js │ │ ├── data-preflight/ │ │ │ ├── data-preflight.js │ │ │ ├── data-preflight.meta.js │ │ │ └── package.json │ │ ├── debug/ │ │ │ ├── debug.js │ │ │ └── package.json │ │ ├── denymount/ │ │ │ ├── denymount.js │ │ │ └── package.json │ │ ├── diff/ │ │ │ ├── diff.js │ │ │ └── package.json │ │ ├── drivelist/ │ │ │ ├── drivelist.js │ │ │ ├── drivelist.meta.js │ │ │ ├── drivelist@3.0.0.js │ │ │ ├── drivelist@3.0.0.meta.js │ │ │ └── package.json │ │ ├── ed25519/ │ │ │ ├── ed25519.js │ │ │ ├── ed25519.meta.js │ │ │ └── package.json │ │ ├── ejs/ │ │ │ ├── ejs.js │ │ │ ├── ejs@0.8.8.js │ │ │ └── package.json │ │ ├── elasticsearch/ │ │ │ ├── elasticsearch.js │ │ │ └── package.json │ │ ├── electron/ │ │ │ ├── electron.js │ │ │ ├── electron.meta.js │ │ │ └── package.json │ │ ├── emailjs/ │ │ │ ├── emailjs.js │ │ │ └── package.json │ │ ├── engine.io/ │ │ │ ├── engine.io.js │ │ │ ├── engine.io@1.8.0.js │ │ │ └── package.json │ │ ├── epoll/ │ │ │ ├── epoll.js │ │ │ ├── epoll.meta.js │ │ │ └── package.json │ │ ├── errorhandler/ │ │ │ ├── errorhandler.js │ │ │ └── package.json │ │ ├── errors/ │ │ │ ├── errors.js │ │ │ └── package.json │ │ ├── eslint/ │ │ │ ├── eslint.js │ │ │ ├── eslint.meta.js │ │ │ └── package.json │ │ ├── etcher-image-write/ │ │ │ ├── etcher-image-write.js │ │ │ ├── etcher-image-write.meta.js │ │ │ └── package.json │ │ ├── exceljs/ │ │ │ ├── exceljs.js │ │ │ └── package.json │ │ ├── exiftool.pl/ │ │ │ ├── exiftool.pl.js │ │ │ ├── exiftool.pl.meta.js │ │ │ └── package.json │ │ ├── express/ │ │ │ ├── express.js │ │ │ ├── express@3.5.3.js │ │ │ └── package.json │ │ ├── express-load/ │ │ │ ├── controllers/ │ │ │ │ └── fixture.js │ │ │ ├── express-load.config.json │ │ │ ├── express-load.js │ │ │ ├── package.json │ │ │ └── routes/ │ │ │ └── fixture.js │ │ ├── express-session/ │ │ │ ├── express-session.js │ │ │ └── package.json │ │ ├── express-with-jade/ │ │ │ ├── express.config.json │ │ │ ├── express.js │ │ │ ├── express.meta.js │ │ │ ├── express@3.0.6.config.json │ │ │ ├── express@3.0.6.js │ │ │ ├── express@3.0.6.meta.js │ │ │ ├── express@3.21.2.config.json │ │ │ ├── express@3.21.2.js │ │ │ ├── express@3.21.2.meta.js │ │ │ ├── package.json │ │ │ └── views/ │ │ │ └── fixture.jade │ │ ├── extender/ │ │ │ ├── extender.js │ │ │ └── package.json │ │ ├── extsprintf/ │ │ │ ├── extsprintf.js │ │ │ └── package.json │ │ ├── faye-websocket/ │ │ │ ├── faye-websocket.js │ │ │ └── package.json │ │ ├── feathers/ │ │ │ ├── feathers.js │ │ │ └── package.json │ │ ├── findup-sync/ │ │ │ ├── findup-sync.js │ │ │ └── package.json │ │ ├── floordate/ │ │ │ ├── floordate.js │ │ │ └── package.json │ │ ├── fmt/ │ │ │ ├── fmt.js │ │ │ └── package.json │ │ ├── formidable/ │ │ │ ├── formidable.js │ │ │ └── package.json │ │ ├── fs-extra/ │ │ │ ├── fs-extra.js │ │ │ ├── fs-extra@0.20.1.js │ │ │ └── package.json │ │ ├── fsevents/ │ │ │ ├── fsevents.js │ │ │ ├── fsevents.meta.js │ │ │ └── package.json │ │ ├── geoip-lite/ │ │ │ ├── geoip-lite.js │ │ │ └── package.json │ │ ├── github/ │ │ │ ├── github.js │ │ │ └── package.json │ │ ├── gm/ │ │ │ ├── gm.js │ │ │ ├── gm.meta.js │ │ │ └── package.json │ │ ├── google-closure-compiler/ │ │ │ ├── google-closure-compiler.js │ │ │ ├── google-closure-compiler.meta.js │ │ │ ├── google-closure-compiler@20180610.0.2.js │ │ │ ├── google-closure-compiler@20180610.0.2.meta.js │ │ │ └── package.json │ │ ├── google-closure-compiler-java/ │ │ │ ├── google-closure-compiler-java.js │ │ │ ├── google-closure-compiler-java.meta.js │ │ │ └── package.json │ │ ├── googleapis/ │ │ │ ├── googleapis.js │ │ │ └── package.json │ │ ├── got/ │ │ │ ├── got.js │ │ │ └── package.json │ │ ├── graceful-fs/ │ │ │ ├── graceful-fs.js │ │ │ ├── graceful-fs@3.0.8.js │ │ │ └── package.json │ │ ├── grpc/ │ │ │ ├── grpc.js │ │ │ ├── grpc.meta.js │ │ │ └── package.json │ │ ├── gulp/ │ │ │ ├── gulp-concat-01.txt │ │ │ ├── gulp-concat-02.txt │ │ │ ├── gulp.js │ │ │ ├── gulp.meta.js │ │ │ ├── gulpfile.js │ │ │ └── package.json │ │ ├── hap-nodejs/ │ │ │ ├── hap-nodejs.js │ │ │ ├── hap-nodejs.meta.js │ │ │ └── package.json │ │ ├── heapdump/ │ │ │ ├── heapdump.js │ │ │ ├── heapdump.meta.js │ │ │ └── package.json │ │ ├── hoek/ │ │ │ ├── hoek.js │ │ │ ├── hoek.meta.js │ │ │ ├── hoek@0.9.1.js │ │ │ └── package.json │ │ ├── home.js │ │ ├── homebridge/ │ │ │ ├── homebridge.js │ │ │ ├── homebridge.meta.js │ │ │ └── package.json │ │ ├── http-proxy/ │ │ │ ├── http-proxy.js │ │ │ └── package.json │ │ ├── http-server/ │ │ │ ├── http-server.js │ │ │ └── package.json │ │ ├── image-size/ │ │ │ ├── image-size.js │ │ │ └── package.json │ │ ├── indexof/ │ │ │ ├── indexof.js │ │ │ └── package.json │ │ ├── inquirer/ │ │ │ ├── inquirer.js │ │ │ └── package.json │ │ ├── j/ │ │ │ ├── j.js │ │ │ ├── package.json │ │ │ └── registry.xls │ │ ├── jade/ │ │ │ ├── jade.js │ │ │ └── package.json │ │ ├── jsdom/ │ │ │ ├── jsdom.js │ │ │ ├── jsdom.meta.js │ │ │ ├── jsdom@8.5.0.js │ │ │ ├── jsdom@8.5.0.meta.js │ │ │ └── package.json │ │ ├── json-stringify-date/ │ │ │ ├── json-stringify-date.js │ │ │ └── package.json │ │ ├── json-stringify-safe/ │ │ │ ├── json-stringify-safe.js │ │ │ ├── json-stringify-safe@4.0.0.js │ │ │ └── package.json │ │ ├── jsonwebtoken/ │ │ │ ├── jsonwebtoken.js │ │ │ └── package.json │ │ ├── kerberos/ │ │ │ ├── kerberos.js │ │ │ ├── kerberos.meta.js │ │ │ ├── kerberos@0.0.10.js │ │ │ ├── kerberos@0.0.10.meta.js │ │ │ └── package.json │ │ ├── knex/ │ │ │ ├── knex.js │ │ │ └── package.json │ │ ├── later/ │ │ │ ├── later.js │ │ │ └── package.json │ │ ├── level/ │ │ │ ├── level.js │ │ │ └── package.json │ │ ├── leveldown/ │ │ │ ├── leveldown.js │ │ │ ├── leveldown.meta.js │ │ │ └── package.json │ │ ├── levelup/ │ │ │ ├── levelup.js │ │ │ ├── levelup.meta.js │ │ │ └── package.json │ │ ├── liftoff/ │ │ │ ├── liftoff.js │ │ │ └── package.json │ │ ├── lodash/ │ │ │ ├── lodash.js │ │ │ └── package.json │ │ ├── log4js/ │ │ │ ├── log4js.js │ │ │ ├── log4js@0.5.8.js │ │ │ ├── log4js@0.6.34.js │ │ │ ├── log4js@1.1.1.js │ │ │ └── package.json │ │ ├── logform/ │ │ │ ├── logform.js │ │ │ └── package.json │ │ ├── machinepack-urls/ │ │ │ ├── machinepack-urls.js │ │ │ ├── machinepack-urls@5.0.0.js │ │ │ └── package.json │ │ ├── main.js │ │ ├── markdown/ │ │ │ ├── markdown.js │ │ │ └── package.json │ │ ├── mdns/ │ │ │ ├── mdns.js │ │ │ ├── mdns.meta.js │ │ │ └── package.json │ │ ├── method-override/ │ │ │ ├── method-override.js │ │ │ └── package.json │ │ ├── microjob/ │ │ │ ├── microjob.js │ │ │ └── package.json │ │ ├── mime/ │ │ │ ├── mime.js │ │ │ ├── mime@1.4.1.js │ │ │ └── package.json │ │ ├── mime-types/ │ │ │ ├── mime-types.js │ │ │ └── package.json │ │ ├── minimatch/ │ │ │ ├── minimatch.js │ │ │ └── package.json │ │ ├── minstache/ │ │ │ ├── minstache.js │ │ │ └── package.json │ │ ├── module-deps/ │ │ │ ├── module-deps.js │ │ │ └── package.json │ │ ├── moment/ │ │ │ ├── moment.js │ │ │ └── package.json │ │ ├── moment-timezone/ │ │ │ ├── moment-timezone.js │ │ │ └── package.json │ │ ├── mongodb/ │ │ │ ├── mongodb.js │ │ │ ├── mongodb.meta.js │ │ │ └── package.json │ │ ├── mongodb-core/ │ │ │ ├── mongodb-core.js │ │ │ ├── mongodb-core@1.0.5.js │ │ │ ├── mongodb-core@1.0.5.meta.js │ │ │ └── package.json │ │ ├── mongoose/ │ │ │ ├── mongoose.js │ │ │ ├── mongoose.meta.js │ │ │ ├── mongoose@3.9.7.js │ │ │ ├── mongoose@3.9.7.meta.js │ │ │ ├── mongoose@4.0.8.js │ │ │ ├── mongoose@4.0.8.meta.js │ │ │ ├── mongoose@4.1.12.js │ │ │ ├── mongoose@4.1.12.meta.js │ │ │ └── package.json │ │ ├── mongoskin/ │ │ │ ├── mongoskin@2.0.3.js │ │ │ ├── mongoskin@2.0.3.meta.js │ │ │ └── package.json │ │ ├── ms/ │ │ │ ├── ms.js │ │ │ └── package.json │ │ ├── msgpack/ │ │ │ ├── msgpack.js │ │ │ ├── msgpack.meta.js │ │ │ └── package.json │ │ ├── multer/ │ │ │ ├── multer.js │ │ │ └── package.json │ │ ├── muri/ │ │ │ ├── muri.js │ │ │ └── package.json │ │ ├── native-or-bluebird/ │ │ │ ├── native-or-bluebird.js │ │ │ └── package.json │ │ ├── natives/ │ │ │ ├── natives.js │ │ │ └── package.json │ │ ├── nconf/ │ │ │ ├── nconf.js │ │ │ └── package.json │ │ ├── nedb/ │ │ │ ├── nedb.js │ │ │ └── package.json │ │ ├── negotiator/ │ │ │ ├── negotiator.js │ │ │ ├── negotiator@0.4.9.js │ │ │ └── package.json │ │ ├── newrelic/ │ │ │ ├── newrelic.js │ │ │ └── package.json │ │ ├── nib/ │ │ │ ├── nib.js │ │ │ └── package.json │ │ ├── nightmare/ │ │ │ ├── nightmare.config.json │ │ │ ├── nightmare.js │ │ │ ├── nightmare.meta.js │ │ │ └── package.json │ │ ├── node-forge/ │ │ │ ├── node-forge.js │ │ │ └── package.json │ │ ├── node-libcurl/ │ │ │ ├── node-libcurl.js │ │ │ ├── node-libcurl.meta.js │ │ │ └── package.json │ │ ├── node-notifier/ │ │ │ ├── node-notifier.js │ │ │ ├── node-notifier.meta.js │ │ │ └── package.json │ │ ├── node-pre-gyp/ │ │ │ ├── node-pre-gyp.js │ │ │ └── package.json │ │ ├── node-redis-pubsub/ │ │ │ ├── node-redis-pubsub.js │ │ │ └── package.json │ │ ├── node-sass/ │ │ │ ├── node-sass.js │ │ │ └── package.json │ │ ├── node-uuid/ │ │ │ ├── node-uuid.js │ │ │ └── package.json │ │ ├── node-xlsx/ │ │ │ ├── ffc.ods │ │ │ ├── node-xlsx.js │ │ │ ├── node-xlsx.meta.js │ │ │ ├── node-xlsx@0.6.0.js │ │ │ ├── package.json │ │ │ └── registry.xls │ │ ├── node-zookeeper-client/ │ │ │ ├── node-zookeeper-client.js │ │ │ └── package.json │ │ ├── nodegit/ │ │ │ ├── nodegit.js │ │ │ ├── nodegit.meta.js │ │ │ └── package.json │ │ ├── nodemailer/ │ │ │ ├── nodemailer.js │ │ │ └── package.json │ │ ├── nodemailer-sendmail-transport/ │ │ │ ├── nodemailer-sendmail-transport.js │ │ │ └── package.json │ │ ├── npm/ │ │ │ ├── npm.meta.js │ │ │ └── package.json │ │ ├── npm-registry-client/ │ │ │ ├── npm-registry-client.js │ │ │ ├── npm-registry-client@6.0.7.js │ │ │ └── package.json │ │ ├── nssocket/ │ │ │ ├── nssocket.js │ │ │ ├── nssocket@0.5.3.js │ │ │ └── package.json │ │ ├── oauth2orize/ │ │ │ ├── oauth2orize.js │ │ │ └── package.json │ │ ├── octobat/ │ │ │ ├── octobat.js │ │ │ └── package.json │ │ ├── open/ │ │ │ ├── open.js │ │ │ ├── open.meta.js │ │ │ └── package.json │ │ ├── opn/ │ │ │ ├── opn.js │ │ │ ├── opn.meta.js │ │ │ └── package.json │ │ ├── optimist/ │ │ │ ├── optimist.js │ │ │ └── package.json │ │ ├── passport/ │ │ │ ├── package.json │ │ │ ├── passport.js │ │ │ └── passport@0.2.2.js │ │ ├── passport-local/ │ │ │ ├── package.json │ │ │ ├── passport-local.js │ │ │ └── passport-local@0.1.6.js │ │ ├── pg/ │ │ │ ├── package.json │ │ │ ├── pg.js │ │ │ ├── pg@3.6.3.js │ │ │ ├── pg@4.0.0.js │ │ │ └── pg@6.4.1.js │ │ ├── pg-cursor/ │ │ │ ├── package.json │ │ │ ├── pg-cursor.js │ │ │ └── pg-cursor.meta.js │ │ ├── pg-query-stream/ │ │ │ ├── package.json │ │ │ ├── pg-query-stream.js │ │ │ ├── pg-query-stream.meta.js │ │ │ ├── pg-query-stream@1.0.0.js │ │ │ └── pg-query-stream@1.0.0.meta.js │ │ ├── pg-types/ │ │ │ ├── package.json │ │ │ ├── pg-types.js │ │ │ └── pg-types@1.0.0.js │ │ ├── pg.js/ │ │ │ ├── package.json │ │ │ ├── pg.js.js │ │ │ ├── pg.js@3.6.2.js │ │ │ └── pg.js@4.1.0.js │ │ ├── pgpass/ │ │ │ ├── package.json │ │ │ └── pgpass.js │ │ ├── phantom/ │ │ │ ├── package.json │ │ │ ├── phantom.js │ │ │ └── phantom.meta.js │ │ ├── phantomjs-prebuilt/ │ │ │ ├── package.json │ │ │ ├── phantomjs-prebuilt.js │ │ │ └── phantomjs-prebuilt.meta.js │ │ ├── pkginfo/ │ │ │ ├── package.json │ │ │ ├── pkginfo.js │ │ │ └── pkginfo@0.2.1.js │ │ ├── pm2/ │ │ │ ├── package.json │ │ │ └── test.it.manually.meta.js │ │ ├── pmx/ │ │ │ ├── package.json │ │ │ ├── pmx.js │ │ │ └── pmx@0.5.9.js │ │ ├── pouchdb/ │ │ │ ├── package.json │ │ │ ├── pouchdb.js │ │ │ └── pouchdb.meta.js │ │ ├── primus/ │ │ │ ├── package.json │ │ │ └── primus.js │ │ ├── primus-emitter/ │ │ │ ├── package.json │ │ │ └── primus-emitter.js │ │ ├── primus-spark-latency/ │ │ │ ├── package.json │ │ │ └── primus-spark-latency.js │ │ ├── publicsuffixlist/ │ │ │ ├── package.json │ │ │ └── publicsuffixlist.js │ │ ├── pug/ │ │ │ ├── package.json │ │ │ └── pug.js │ │ ├── punt/ │ │ │ ├── package.json │ │ │ ├── punt.js │ │ │ └── punt@1.0.1.js │ │ ├── puppeteer/ │ │ │ ├── package.json │ │ │ ├── puppeteer.js │ │ │ └── puppeteer.meta.js │ │ ├── pwd/ │ │ │ ├── package.json │ │ │ ├── pwd.js │ │ │ └── pwd@0.0.4.js │ │ ├── q/ │ │ │ ├── package.json │ │ │ └── q.js │ │ ├── raven/ │ │ │ ├── package.json │ │ │ └── raven.js │ │ ├── rc/ │ │ │ ├── .fixture.for.rc │ │ │ ├── package.json │ │ │ ├── rc.config.json │ │ │ └── rc.js │ │ ├── readable-stream/ │ │ │ ├── package.json │ │ │ └── readable-stream.js │ │ ├── rechoir/ │ │ │ ├── fixture.coffee │ │ │ ├── package.json │ │ │ ├── rechoir.config.json │ │ │ ├── rechoir.js │ │ │ └── rechoir.meta.js │ │ ├── redis/ │ │ │ ├── package.json │ │ │ ├── redis.js │ │ │ ├── redis@1.0.0.js │ │ │ ├── redis@2.0.1.js │ │ │ ├── redis@2.1.0.js │ │ │ ├── redis@2.2.5.js │ │ │ ├── redis@2.3.1.js │ │ │ └── redis@2.4.2.js │ │ ├── redis-parser/ │ │ │ ├── package.json │ │ │ └── redis-parser.js │ │ ├── redis-with-hiredis/ │ │ │ ├── package.json │ │ │ ├── redis.js │ │ │ ├── redis.meta.js │ │ │ ├── redis@1.0.0.js │ │ │ ├── redis@1.0.0.meta.js │ │ │ ├── redis@2.0.1.js │ │ │ ├── redis@2.0.1.meta.js │ │ │ ├── redis@2.1.0.js │ │ │ ├── redis@2.1.0.meta.js │ │ │ ├── redis@2.2.5.js │ │ │ ├── redis@2.2.5.meta.js │ │ │ ├── redis@2.3.1.js │ │ │ ├── redis@2.3.1.meta.js │ │ │ ├── redis@2.4.2.js │ │ │ └── redis@2.4.2.meta.js │ │ ├── regression/ │ │ │ ├── package.json │ │ │ ├── regression.js │ │ │ └── regression@1.4.0.js │ │ ├── reload/ │ │ │ ├── package.json │ │ │ ├── reload.js │ │ │ ├── reload.meta.js │ │ │ ├── reload@2.1.0.js │ │ │ └── reload@2.1.0.meta.js │ │ ├── request/ │ │ │ ├── package.json │ │ │ └── request.js │ │ ├── require-uncached/ │ │ │ ├── package.json │ │ │ └── require-uncached.js │ │ ├── require_optional/ │ │ │ ├── package.json │ │ │ ├── require_optional.config.json │ │ │ └── require_optional.js │ │ ├── s3/ │ │ │ ├── package.json │ │ │ └── s3.js │ │ ├── safe_datejs/ │ │ │ ├── package.json │ │ │ └── safe_datejs.js │ │ ├── sails/ │ │ │ ├── package.json │ │ │ ├── sails.js │ │ │ └── sails.meta.js │ │ ├── sax/ │ │ │ ├── package.json │ │ │ └── sax.js │ │ ├── scrypt/ │ │ │ ├── package.json │ │ │ ├── scrypt.js │ │ │ ├── scrypt.meta.js │ │ │ ├── scrypt@5.4.1.js │ │ │ └── scrypt@5.4.1.meta.js │ │ ├── semver/ │ │ │ ├── package.json │ │ │ └── semver.js │ │ ├── sequelize/ │ │ │ ├── package.json │ │ │ ├── sequelize.config.json │ │ │ ├── sequelize.js │ │ │ ├── sequelize.meta.js │ │ │ ├── sequelize@3.30.4.config.json │ │ │ ├── sequelize@3.30.4.js │ │ │ └── sequelize@3.30.4.meta.js │ │ ├── serialport/ │ │ │ ├── package.json │ │ │ ├── serialport.js │ │ │ └── serialport.meta.js │ │ ├── sha3/ │ │ │ ├── package.json │ │ │ ├── sha3.js │ │ │ └── sha3.meta.js │ │ ├── sharp/ │ │ │ ├── package.json │ │ │ ├── sharp.js │ │ │ └── sharp.meta.js │ │ ├── shelljs/ │ │ │ ├── package.json │ │ │ ├── shelljs.js │ │ │ ├── shelljs@0.1.4.js │ │ │ ├── shelljs@0.6.0.js │ │ │ └── shelljs@0.7.6.js │ │ ├── sinon/ │ │ │ ├── package.json │ │ │ ├── sinon.js │ │ │ └── sinon@1.1.0.js │ │ ├── socket.io/ │ │ │ ├── package.json │ │ │ ├── socket.io.js │ │ │ ├── socket.io@1.4.8.js │ │ │ ├── socket.io@1.6.0.js │ │ │ └── socket.io@1.7.0.js │ │ ├── socket.io-client/ │ │ │ ├── package.json │ │ │ ├── socket.io-client.js │ │ │ ├── socket.io-client@0.9.17.js │ │ │ ├── socket.io-client@1.0.6.js │ │ │ └── socket.io-client@1.7.0.js │ │ ├── sqip/ │ │ │ ├── package.json │ │ │ └── sqip.js │ │ ├── sqlite3/ │ │ │ ├── package.json │ │ │ ├── sqlite3.js │ │ │ └── sqlite3.meta.js │ │ ├── stamp.js │ │ ├── steam/ │ │ │ ├── package.json │ │ │ ├── steam.js │ │ │ └── steam.meta.js │ │ ├── steam-crypto/ │ │ │ ├── package.json │ │ │ └── steam-crypto.js │ │ ├── stripe/ │ │ │ ├── package.json │ │ │ ├── stripe.js │ │ │ └── stripe@3.9.0.js │ │ ├── stripe-webhook-middleware/ │ │ │ ├── package.json │ │ │ └── stripe-webhook-middleware.js │ │ ├── strong-globalize/ │ │ │ ├── package.json │ │ │ └── strong-globalize.js │ │ ├── stylus/ │ │ │ ├── external.css │ │ │ ├── package.json │ │ │ ├── stylus.config.json │ │ │ └── stylus.js │ │ ├── supervisor/ │ │ │ ├── fixture.js │ │ │ ├── package.json │ │ │ ├── supervisor.js │ │ │ └── supervisor.meta.js │ │ ├── svgo/ │ │ │ ├── package.json │ │ │ └── svgo.js │ │ ├── tabtab/ │ │ │ ├── package.json │ │ │ └── tabtab.js │ │ ├── tesseract.js/ │ │ │ ├── package.json │ │ │ ├── tesseract.js.js │ │ │ └── tesseract.js.meta.js │ │ ├── throng/ │ │ │ ├── package.json │ │ │ ├── throng.js │ │ │ └── throng.meta.js │ │ ├── time/ │ │ │ ├── package.json │ │ │ ├── time.js │ │ │ └── time.meta.js │ │ ├── times.js │ │ ├── tinify/ │ │ │ ├── package.json │ │ │ └── tinify.js │ │ ├── tiny-worker/ │ │ │ ├── fixture.js │ │ │ ├── package.json │ │ │ └── tiny-worker.js │ │ ├── tmp/ │ │ │ ├── package.json │ │ │ └── tmp.js │ │ ├── transformers/ │ │ │ ├── package.json │ │ │ └── transformers.js │ │ ├── uglify-js/ │ │ │ ├── package.json │ │ │ ├── uglify-js.js │ │ │ └── uglify-js@2.7.5.js │ │ ├── umd/ │ │ │ ├── package.json │ │ │ ├── umd.js │ │ │ └── umd@2.1.0.js │ │ ├── underscore/ │ │ │ ├── package.json │ │ │ └── underscore.js │ │ ├── union/ │ │ │ ├── package.json │ │ │ └── union.js │ │ ├── update-notifier/ │ │ │ ├── package.json │ │ │ ├── update-notifier.js │ │ │ └── update-notifier.meta.js │ │ ├── usage/ │ │ │ ├── package.json │ │ │ ├── usage.js │ │ │ └── usage.meta.js │ │ ├── v8flags/ │ │ │ ├── package.json │ │ │ ├── v8flags.js │ │ │ └── v8flags@2.1.1.js │ │ ├── verror/ │ │ │ ├── package.json │ │ │ └── verror.js │ │ ├── voc/ │ │ │ ├── package.json │ │ │ └── voc.js │ │ ├── webdriverio/ │ │ │ ├── package.json │ │ │ └── webdriverio.js │ │ ├── winston/ │ │ │ ├── package.json │ │ │ └── winston.js │ │ ├── winston-uber/ │ │ │ ├── package.json │ │ │ └── winston-uber.js │ │ ├── ws/ │ │ │ ├── package.json │ │ │ ├── ws.js │ │ │ └── ws@0.5.0.js │ │ ├── xlsx/ │ │ │ ├── ffc.ods │ │ │ ├── package.json │ │ │ ├── registry.xls │ │ │ └── xlsx.js │ │ ├── xml2js/ │ │ │ ├── package.json │ │ │ └── xml2js.js │ │ ├── yargs/ │ │ │ ├── package.json │ │ │ └── yargs.js │ │ └── zeromq/ │ │ ├── package.json │ │ ├── zeromq.js │ │ └── zeromq.meta.js │ ├── test-80-compression/ │ │ ├── .gitignore │ │ ├── main.js │ │ ├── test-empty.js │ │ └── test-x.js │ ├── test-80-compression-node-opcua/ │ │ ├── .gitignore │ │ ├── main.js │ │ ├── package.json │ │ ├── test-empty.js │ │ ├── test-x.js │ │ └── test-y.js │ ├── test-80-compression-various-file-access/ │ │ ├── main.js │ │ ├── myfile.txt │ │ ├── package.json │ │ ├── test.js │ │ └── test_with_new_fs_promises.js │ ├── test-99-#1120-mkdir-mountpoints/ │ │ ├── main.js │ │ └── test-x-index.js │ ├── test-99-#1121-regexp-mountpoints/ │ │ ├── main.js │ │ ├── plugins-D-ext/ │ │ │ └── test-y-require-D.js │ │ └── test-x-index.js │ ├── test-99-#1130/ │ │ ├── .gitignore │ │ ├── files/ │ │ │ ├── a.js │ │ │ └── b.js │ │ ├── main.js │ │ ├── package.json │ │ └── read.js │ ├── test-99-#1135/ │ │ ├── .gitignore │ │ ├── index.js │ │ ├── main.js │ │ └── package.json │ ├── test-99-#1191/ │ │ ├── .gitignore │ │ ├── index.js │ │ ├── main.js │ │ └── package.json │ ├── test-99-#1192/ │ │ ├── .gitignore │ │ ├── main.js │ │ ├── package.json │ │ ├── public/ │ │ │ └── views/ │ │ │ └── index.pug │ │ └── src/ │ │ └── index.js │ ├── test-99-#1207/ │ │ ├── .gitignore │ │ ├── index.js │ │ └── main.js │ ├── test-99-#1505/ │ │ ├── .gitignore │ │ ├── files/ │ │ │ └── test.txt │ │ ├── main.js │ │ ├── package.json │ │ └── stat.js │ ├── test-99-#1861/ │ │ ├── index.js │ │ ├── launch.bat │ │ └── main.js │ ├── test-99-#420-copy-from-snapshot/ │ │ ├── .gitignore │ │ ├── copy.js │ │ ├── input/ │ │ │ └── test.json │ │ ├── main.js │ │ └── package.json │ ├── test-99-#775/ │ │ ├── a.js │ │ ├── b.js │ │ ├── main.js │ │ └── package.json │ ├── test-99-#938-withfiletypes/ │ │ ├── .gitignore │ │ ├── main.js │ │ ├── package.json │ │ └── read.js │ ├── test.js │ └── utils.js └── tsconfig.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .eslintignore ================================================ lib-es5 node_modules dist ================================================ FILE: .eslintrc ================================================ { "extends": ["airbnb-base", "prettier"], "rules": { "no-bitwise": "off", "no-continue": "off", "no-await-in-loop": "off", "no-constant-condition": "off", "no-param-reassign": "off", "consistent-return": "off", "no-restricted-syntax": "off", "import/prefer-default-export": "off", "camelcase": "off" }, "overrides": [ { "files": ["*.ts"], "extends": [ "airbnb-typescript/base", "plugin:@typescript-eslint/recommended", "prettier" ], "parser": "@typescript-eslint/parser", "parserOptions": { "project": "./tsconfig.json" }, "rules": { "@typescript-eslint/explicit-module-boundary-types": "off", "consistent-return": "off", "import/prefer-default-export": "off", "no-await-in-loop": "off", "no-bitwise": "off", "no-constant-condition": "off", "no-continue": "off", "no-param-reassign": "off", "no-restricted-syntax": "off" } }, { "files": ["prelude/**/*"], "rules": { "strict": "off" } }, { "files": ["test/**/*"], "rules": { "array-callback-return": "off", "func-names": "off", "global-require": "off", "guard-for-in": "off", "import/extensions": "off", "import/no-dynamic-require": "off", "import/no-extraneous-dependencies": "off", "import/newline-after-import": "off", "import/no-unresolved": "off", "import/no-useless-path-segments": "off", "import/order": "off", "no-console": "off", "no-lonely-if": "off", "no-multi-assign": "off", "no-undef": "off", "no-else-return": "off", "no-use-before-define": "off", "object-shorthand": "off", "one-var": "off", "prefer-arrow-callback": "off", "prefer-destructuring": "off", "prefer-object-spread": "off", "prefer-template": "off", "strict": ["error", "global"] } } ] } ================================================ FILE: .github/ISSUE_TEMPLATE/01_bug_report.yml ================================================ name: 🐞 Bug Report description: Create a bug report for pkg labels: 'template: bug' body: - type: markdown attributes: value: Thanks for taking the time to file a bug report! Please fill out this form as completely as possible. - type: markdown attributes: value: If you leave out sections there is a high likelihood it will be moved to the GitHub Discussions "Question" section. - type: markdown attributes: value: 'Please first search the repository for similar issues and discussions.' - type: input attributes: label: What version of pkg are you using? description: '`pkg --version` - For example: 5.4.1' validations: required: true - type: input attributes: label: What version of Node.js are you using? description: '`node --version` - For example: 16.0.0' validations: required: true - type: input attributes: label: What operating system are you using? description: 'For example: macOS, Windows, Ubuntu 20.04' validations: required: true - type: input attributes: label: What CPU architecture are you using? description: 'For example: x86_64, arm64, armv7, Intel 12900K, Apple M1' validations: required: true - type: input attributes: label: What Node versions, OSs and CPU architectures are you building for? description: 'For example: default, node18, node18-linux-x64, node16-win-arm64' validations: required: true - type: textarea attributes: label: Describe the Bug description: A clear and concise description of what the bug is. validations: required: true - type: textarea attributes: label: Expected Behavior description: A clear and concise description of what you expected to happen. validations: required: true - type: textarea attributes: label: To Reproduce description: Steps to reproduce the behavior, please provide a clear code snippets that always reproduces the issue or a GitHub repository. Screenshots can be provided in the issue body below. validations: required: true - type: markdown attributes: value: Before posting the issue go through the steps you've written down to make sure the steps provided are detailed and clear. - type: markdown attributes: value: Contributors should be able to follow the steps provided in order to reproduce the bug. - type: markdown attributes: value: These steps are used to add integration tests to ensure the same issue does not happen again. Thanks in advance! ================================================ FILE: .github/ISSUE_TEMPLATE/02_regression.yml ================================================ name: ⏮️ Regression report description: Report a bug not seen in an earlier version of pkg labels: 'template: regression' body: - type: markdown attributes: value: Thanks for taking the time to file a bug report! Please fill out this form as completely as possible. - type: markdown attributes: value: If you leave out sections there is a high likelihood it will be moved to the GitHub Discussions "Question" section. - type: markdown attributes: value: 'Please first search the repository for similar issues and discussions.' - type: input attributes: label: What version of pkg are you using? description: '`pkg --version` - For example: 5.4.1' validations: required: true - type: input attributes: label: Which version(s) of pkg work for you? description: '`pkg --version` - For example: < 5.4.1, 5.3.0, 4.5.0' validations: required: true - type: input attributes: label: What version of Node.js are you using? description: '`node --version` - For example: 16.0.0' validations: required: true - type: input attributes: label: What operating system are you using? description: 'For example: macOS, Windows, Ubuntu 20.04' validations: required: true - type: input attributes: label: What CPU architecture are you using? description: 'For example: x86_64, arm64, armv7, Intel 12900K, Apple M1' validations: required: true - type: input attributes: label: What Node versions, OSs and CPU architectures are you building for? description: 'For example: default, node18, node18-linux-x64, node16-win-arm64' validations: required: true - type: textarea attributes: label: Describe the Bug description: A clear and concise description of what the bug is. validations: required: true - type: textarea attributes: label: Expected Behavior description: A clear and concise description of what you expected to happen. validations: required: true - type: textarea attributes: label: To Reproduce description: Steps to reproduce the behavior, please provide a clear code snippets that always reproduces the issue or a GitHub repository. Screenshots can be provided in the issue body below. validations: required: true - type: markdown attributes: value: Before posting the issue go through the steps you've written down to make sure the steps provided are detailed and clear. - type: markdown attributes: value: Contributors should be able to follow the steps provided in order to reproduce the bug. - type: markdown attributes: value: These steps are used to add integration tests to ensure the same issue does not happen again. Thanks in advance! ================================================ FILE: .github/ISSUE_TEMPLATE/config.yml ================================================ contact_links: - name: 💡 Feature Request url: https://github.com/vercel/pkg/discussions/new about: Share ideas for new features - name: ❓ Question url: https://github.com/vercel/pkg/discussions/new about: General questions ================================================ FILE: .github/workflows/ci.yml ================================================ name: CI on: push: branches: - main pull_request: jobs: test: strategy: fail-fast: false # prevent test to stop if one fails matrix: node-version: [14.x, 16.x, 18.x] os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - uses: actions/cache@v3 with: path: ~/.pkg-cache/ key: ${{ matrix.os }}-${{ matrix.node-version }} - run: yarn install - if: matrix['node-version'] == '18.x' && matrix['os'] == 'ubuntu-latest' run: yarn lint - run: yarn build - run: yarn test ================================================ FILE: .github/workflows/close-stale.yml ================================================ name: 'Close stale issues' on: schedule: - cron: '0 0 * * *' jobs: stale: runs-on: ubuntu-latest steps: - uses: actions/stale@v3 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label' close-issue-message: 'This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.' stale-pr-message: 'This pull-request is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this pull-request entirely you can add the no-stale label' close-pr-message: 'This pull-request is now closed due to inactivity, you can of course reopen or reference this pull-request if you see fit.' days-before-stale: 90 days-before-close: 5 exempt-issue-labels: 'no-stale,enhancement' exempt-pr-labels: 'no-stale' ================================================ FILE: .gitignore ================================================ # build output /lib-es5 # dependencies /node_modules # logs npm-debug.log # General macOS .DS_Store examples/.DS_Store # Example pkg'd application examples/express/express-example # Example dependencies examples/express/node_modules # Editors .vscode/ yarn-error.log tsconfig.tsbuildinfo ================================================ FILE: .prettierignore ================================================ lib-es5/ ================================================ FILE: .yarnrc ================================================ save-prefix "" ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2021 Vercel, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # `pkg` > [!IMPORTANT] > `pkg` has been deprecated with `5.8.1` as the last release. There are a number of successful forked versions of `pkg` already with various feature additions. Further, we’re excited about Node.js 21’s support for [single executable applications](https://nodejs.org/api/single-executable-applications.html). Thank you for the support and contributions over the years. The repository will remain open and archived. This command line interface enables you to package your Node.js project into an executable that can be run even on devices without Node.js installed. ## Use Cases - Make a commercial version of your application without sources - Make a demo/evaluation/trial version of your app without sources - Instantly make executables for other platforms (cross-compilation) - Make some kind of self-extracting archive or installer - No need to install Node.js and npm to run the packaged application - No need to download hundreds of files via `npm install` to deploy your application. Deploy it as a single file - Put your assets inside the executable to make it even more portable - Test your app against new Node.js version without installing it ## Usage ```sh npm install -g pkg ``` After installing it, run `pkg --help` without arguments to see list of options: ```console pkg [options] Options: -h, --help output usage information -v, --version output pkg version -t, --targets comma-separated list of targets (see examples) -c, --config package.json or any json file with top-level config --options bake v8 options into executable to run with them on -o, --output output file name or template for several files --out-path path to save output one or more executables -d, --debug show more information during packaging process [off] -b, --build don't download prebuilt base binaries, build them --public speed up and disclose the sources of top-level project --public-packages force specified packages to be considered public --no-bytecode skip bytecode generation and include source files as plain js --no-native-build skip native addons build --no-signature skip signature of the final executable on macos --no-dict comma-separated list of packages names to ignore dictionaries. Use --no-dict * to disable all dictionaries -C, --compress [default=None] compression algorithm = Brotli or GZip Examples: – Makes executables for Linux, macOS and Windows $ pkg index.js – Takes package.json from cwd and follows 'bin' entry $ pkg . – Makes executable for particular target machine $ pkg -t node16-win-arm64 index.js – Makes executables for target machines of your choice $ pkg -t node16-linux,node18-linux,node16-win index.js – Bakes '--expose-gc' and '--max-heap-size=34' into executable $ pkg --options "expose-gc,max-heap-size=34" index.js – Consider packageA and packageB to be public $ pkg --public-packages "packageA,packageB" index.js – Consider all packages to be public $ pkg --public-packages "*" index.js – Bakes '--expose-gc' into executable $ pkg --options expose-gc index.js – reduce size of the data packed inside the executable with GZip $ pkg --compress GZip index.js ``` The entrypoint of your project is a mandatory CLI argument. It may be: - Path to entry file. Suppose it is `/path/app.js`, then packaged app will work the same way as `node /path/app.js` - Path to `package.json`. `Pkg` will follow `bin` property of the specified `package.json` and use it as entry file. - Path to directory. `Pkg` will look for `package.json` in the specified directory. See above. ### Targets `pkg` can generate executables for several target machines at a time. You can specify a comma-separated list of targets via `--targets` option. A canonical target consists of 3 elements, separated by dashes, for example `node18-macos-x64` or `node14-linux-arm64`: - **nodeRange** (node8), node10, node12, node14, node16 or latest - **platform** alpine, linux, linuxstatic, win, macos, (freebsd) - **arch** x64, arm64, (armv6, armv7) (element) is unsupported, but you may try to compile yourself. You may omit any element (and specify just `node14` for example). The omitted elements will be taken from current platform or system-wide Node.js installation (its version and arch). There is also an alias `host`, that means that all 3 elements are taken from current platform/Node.js. By default targets are `linux,macos,win` for current Node.js version and arch. If you want to generate executable for different architectures, note that by default `pkg` has to run the executable of the **target** arch to generate bytecodes: - Linux: configure binfmt with [QEMU](https://wiki.debian.org/QemuUserEmulation). - macOS: possible to build `x64` on `arm64` with `Rosetta 2` but not opposite. - Windows: possible to build `x64` on `arm64` with `x64 emulation` but not opposite. - or, disable bytecode generation with `--no-bytecode --public-packages "*" --public`. `macos-arm64` is experimental. Be careful about the [mandatory code signing requirement](https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_0_1-universal-apps-release-notes). The final executable has to be signed (ad-hoc signature is sufficient) with `codesign` utility of macOS (or `ldid` utility on Linux). Otherwise, the executable will be killed by kernel and the end-user has no way to permit it to run at all. `pkg` tries to ad-hoc sign the final executable. If necessary, you can replace this signature with your own trusted Apple Developer ID. To be able to generate executables for all supported architectures and platforms, run `pkg` on a Linux host with binfmt (`QEMU` emulation) configured and `ldid` installed. ### Config During packaging process `pkg` parses your sources, detects calls to `require`, traverses the dependencies of your project and includes them into executable. In most cases you don't need to specify anything manually. However your code may have `require(variable)` calls (so called non-literal argument to `require`) or use non-javascript files (for example views, css, images etc). ```js require('./build/' + cmd + '.js'); path.join(__dirname, 'views/' + viewName); ``` Such cases are not handled by `pkg`. So you must specify the files - scripts and assets - manually in `pkg` property of your `package.json` file. ```json "pkg": { "scripts": "build/**/*.js", "assets": "views/**/*", "targets": [ "node14-linux-arm64" ], "outputPath": "dist" } ``` The above example will include everything in `assets/` and every .js file in `build/`, build only for `node14-linux-arm64`, and place the executable inside `dist/`. You may also specify arrays of globs: ``` "assets": [ "assets/**/*", "images/**/*" ] ``` Just be sure to call `pkg package.json` or `pkg .` to make use of `package.json` configuration. ### Scripts `scripts` is a [glob](https://github.com/sindresorhus/globby) or list of globs. Files specified as `scripts` will be compiled using `v8::ScriptCompiler` and placed into executable without sources. They must conform to the JS standards of those Node.js versions you target (see [Targets](#targets)), i.e. be already transpiled. ### Assets `assets` is a [glob](https://github.com/sindresorhus/globby) or list of globs. Files specified as `assets` will be packaged into executable as raw content without modifications. Javascript files may also be specified as `assets`. Their sources will not be stripped as it improves execution performance of the files and simplifies debugging. See also [Detecting assets in source code](#detecting-assets-in-source-code) and [Snapshot filesystem](#snapshot-filesystem). ### Options Node.js application can be called with runtime options (belonging to Node.js or V8). To list them type `node --help` or `node --v8-options`. You can "bake" these runtime options into packaged application. The app will always run with the options turned on. Just remove `--` from option name. You can specify multiple options by joining them in a single string, comma (`,`) separated: ```sh pkg app.js --options expose-gc pkg app.js --options max_old_space_size=4096 pkg app.js --options max-old-space-size=1024,tls-min-v1.0,expose-gc ``` ### Output You may specify `--output` if you create only one executable or `--out-path` to place executables for multiple targets. ### Debug Pass `--debug` to `pkg` to get a log of packaging process. If you have issues with some particular file (seems not packaged into executable), it may be useful to look through the log. ### Bytecode (reproducibility) By default, your source code is precompiled to v8 bytecode before being written to the output file. To disable this feature, pass `--no-bytecode` to `pkg`. #### Why would you want to do this? If you need a reproducible build process where your executable hashes (e.g. md5, sha1, sha256, etc.) are the same value between builds. Because compiling bytecode is not deterministic (see [here](https://ui.adsabs.harvard.edu/abs/2019arXiv191003478C/abstract) or [here](https://medium.com/dailyjs/understanding-v8s-bytecode-317d46c94775)) it results in executables with differing hashed values. Disabling bytecode compilation allows a given input to always have the same output. #### Why would you NOT want to do this? While compiling to bytecode does not make your source code 100% secure, it does add a small layer of security/privacy/obscurity to your source code. Turning off bytecode compilation causes the raw source code to be written directly to the executable file. If you're on \*nix machine and would like an example, run `pkg` with the `--no-bytecode` flag, and use the GNU strings tool on the output. You then should be able to grep your source code. #### Other considerations Specifying `--no-bytecode` will fail if there are any packages in your project that aren't explicitly marked as public by the `license` in their `package.json`. By default, `pkg` will check the license of each package and make sure that stuff that isn't meant for the public will only be included as bytecode. If you do require building pkg binaries for other architectures and/or depend on a package with a broken `license` in its `package.json`, you can override this behaviour by either explicitly whitelisting packages to be public using `--public-packages "packageA,packageB"` or setting all packages to public using `--public-packages "*"` ### Build `pkg` has so called "base binaries" - they are actually same `node` executables but with some patches applied. They are used as a base for every executable `pkg` creates. `pkg` downloads precompiled base binaries before packaging your application. If you prefer to compile base binaries from source instead of downloading them, you may pass `--build` option to `pkg`. First ensure your computer meets the requirements to compile original Node.js: [BUILDING.md](https://github.com/nodejs/node/blob/HEAD/BUILDING.md) See [pkg-fetch](https://github.com/vercel/pkg-fetch) for more info. ### Compression Pass `--compress Brotli` or `--compress GZip` to `pkg` to compress further the content of the files store in the exectable. This option can reduce the size of the embedded file system by up to 60%. The startup time of the application might be reduced slightly. `-C` can be used as a shortcut for `--compress `. ### Environment | Var | Description | | -------------- | ----------------------------------------------------------------------------------------- | | PKG_CACHE_PATH | Used to specify a custom path for node binaries cache folder. Default is `~/.pkg-cache` | | PKG_IGNORE_TAG | Allows to ignore additional folder created on `PKG_CACHE_PATH` matching pkg-fetch version | | MAKE_JOB_COUNT | Allow configuring number of processes used for compiling | Examples ```bash # 1 - Using export export PKG_CACHE_PATH=/my/cache pkg app.js # 2 - Passing it before the script PKG_CACHE_PATH=/my/cache pkg app.js ``` ## Usage of packaged app Command line call to packaged app `./app a b` is equivalent to `node app.js a b` ## Snapshot filesystem During packaging process `pkg` collects project files and places them into executable. It is called a snapshot. At run time the packaged application has access to snapshot filesystem where all that files reside. Packaged files have `/snapshot/` prefix in their paths (or `C:\snapshot\` in Windows). If you used `pkg /path/app.js` command line, then `__filename` value will be likely `/snapshot/path/app.js` at run time. `__dirname` will be `/snapshot/path` as well. Here is the comparison table of path-related values: | value | with `node` | packaged | comments | | ----------------------------- | --------------- | ------------------------ | ------------------------------ | | \_\_filename | /project/app.js | /snapshot/project/app.js | | \_\_dirname | /project | /snapshot/project | | process.cwd() | /project | /deploy | suppose the app is called ... | | process.execPath | /usr/bin/nodejs | /deploy/app-x64 | `app-x64` and run in `/deploy` | | process.argv[0] | /usr/bin/nodejs | /deploy/app-x64 | | process.argv[1] | /project/app.js | /snapshot/project/app.js | | process.pkg.entrypoint | undefined | /snapshot/project/app.js | | process.pkg.defaultEntrypoint | undefined | /snapshot/project/app.js | | require.main.filename | /project/app.js | /snapshot/project/app.js | Hence, in order to make use of a file collected at packaging time (`require` a javascript file or serve an asset) you should take `__filename`, `__dirname`, `process.pkg.defaultEntrypoint` or `require.main.filename` as a base for your path calculations. For javascript files you can just `require` or `require.resolve` because they use current `__dirname` by default. For assets use `path.join(__dirname, '../path/to/asset')`. Learn more about `path.join` in [Detecting assets in source code](#detecting-assets-in-source-code). On the other hand, in order to access real file system at run time (pick up a user's external javascript plugin, json configuration or even get a list of user's directory) you should take `process.cwd()` or `path.dirname(process.execPath)`. ## Detecting assets in source code When `pkg` encounters `path.join(__dirname, '../path/to/asset')`, it automatically packages the file specified as an asset. See [Assets](#assets). Pay attention that `path.join` must have two arguments and the last one must be a string literal. This way you may even avoid creating `pkg` config for your project. ## Native addons Native addons (`.node` files) use is supported. When `pkg` encounters a `.node` file in a `require` call, it will package this like an asset. In some cases (like with the `bindings` package), the module path is generated dynamicaly and `pkg` won't be able to detect it. In this case, you should add the `.node` file directly in the `assets` field in `package.json`. The way Node.js requires native addon is different from a classic JS file. It needs to have a file on disk to load it, but `pkg` only generates one file. To circumvent this, `pkg` will create a temporary file on the disk. These files will stay on the disk after the process has exited and will be used again on the next process launch. When a package, that contains a native module, is being installed, the native module is compiled against current system-wide Node.js version. Then, when you compile your project with `pkg`, pay attention to `--target` option. You should specify the same Node.js version as your system-wide Node.js to make compiled executable compatible with `.node` files. Note that fully static Node binaries are not capable of loading native bindings, so you may not use Node bindings with `linuxstatic`. ## API `const { exec } = require('pkg')` `exec(args)` takes an array of command line arguments and returns a promise. For example: ```js await exec(['app.js', '--target', 'host', '--output', 'app.exe']); // do something with app.exe, run, test, upload, deploy, etc ``` ## Troubleshooting ### Error: ENOENT: no such file or directory, uv_chdir This error can be caused by deleting the directory the application is run from. Or, generally, deleting `process.cwd()` directory when the application is running. ### Error: ERR_INSPECTOR_NOT_AVAILABLE This error can be caused by using `NODE_OPTIONS` variable to force to run `node` with the debug mode enabled. Debugging options are disallowed , as **pkg** executables are usually used for production environments. If you do need to use inspector, you can [build a debuggable Node.js](https://github.com/vercel/pkg/issues/93#issuecomment-301210543) yourself. ### Error: require(...).internalModuleStat is not a function This error can be caused by using `NODE_OPTIONS` variable with some bootstrap or `node` options causing conflicts with **pkg**. Some IDEs, such as **VS Code**, may add this env variable automatically. You could check on **Unix systems** (Linux/macOS) in `bash`: ```bash $ printenv | grep NODE ``` ## Advanced ### exploring virtual file system embedded in debug mode When you are using the `--debug` flag when building your executable, `pkg` add the ability to display the content of the virtual file system and the symlink table on the console, when the application starts, providing that the environement variable DEBUG_PKG is set. This feature can be useful to inspect if symlinks are correctly handled, and check that all the required files for your application are properly incorporated to the final executable. $ pkg --debug app.js -o output $ DEBUG_PKG=1 output or C:\> pkg --debug app.js -o output.exe C:\> set DEBUG_PKG=1 C:\> output.exe Note: make sure not to use --debug flag in production. ================================================ FILE: dictionary/.eslintrc.json ================================================ { "parserOptions": { "sourceType": "script" } } ================================================ FILE: dictionary/angular-bridge.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/any-promise.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/async.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/aws-sdk.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['apis/*.json', 'lib/services/*.js'], }, }; ================================================ FILE: dictionary/babel-core.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/batch.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/bcrypt.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/better-sqlite3.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/bignum.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/bindings.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/blessed.js ================================================ 'use strict'; // https://github.com/chjj/blessed/issues/298 module.exports = { pkg: { scripts: ['lib/widgets/*.js'], }, }; ================================================ FILE: dictionary/body-parser.js ================================================ 'use strict'; module.exports = { pkg: { scripts: [ 'lib/types/*.js', // for 1.4-1.13 ], }, }; ================================================ FILE: dictionary/browserify.js ================================================ 'use strict'; module.exports = { pkg: { assets: ['bin/*.txt'], }, }; ================================================ FILE: dictionary/bson.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/buffermaker.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/*.js'], }, }; ================================================ FILE: dictionary/bunyan.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'lib/bunyan.js': ["mv = require('mv' + '');", "mv = require('mv');"], }, }, }; ================================================ FILE: dictionary/busboy.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/types/*.js'], }, }; ================================================ FILE: dictionary/bytes.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/callsites.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/chokidar.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/coffee-script.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/coffee-script/*.js'], }, }; ================================================ FILE: dictionary/colors.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/compression.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/compressjs.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/*.js'], }, }; ================================================ FILE: dictionary/connect-mongo.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/connect-mongodb.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/connect-redis.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/connect.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/middleware/*.js'], assets: [ 'lib/public/**/*', // for connect@2.3 ], }, }; ================================================ FILE: dictionary/consolidate.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/cookie-parser.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/cookie.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/cors.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/cron.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/cross-env.js ================================================ 'use strict'; module.exports = { pkg: { patches: { // author is mistaken to point package.json.main to // src/index.js (that is es6) instead of dist/index.js (es5) 'src/index.js': [{ do: 'erase' }, ''], }, }, }; ================================================ FILE: dictionary/cross-spawn-async.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/curve25519.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/data-preflight.js ================================================ 'use strict'; module.exports = { pkg: { assets: ['src/view/**/*', 'src/js/view/**/*'], }, }; ================================================ FILE: dictionary/debug.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/denymount.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/diff.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/drivelist.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'build/scripts.js': [ "path.join(__dirname, '..', 'scripts')", "path.join(path.dirname(process.execPath), 'drivelist')", ], 'lib/scripts.js': [ "path.join(__dirname, '..', 'scripts')", "path.join(path.dirname(process.execPath), 'drivelist')", // for 4.0.0 ], }, deployFiles: [ ['build/Release/drivelist.node', 'drivelist.node'], ['scripts/darwin.sh', 'drivelist/darwin.sh'], ['scripts/linux.sh', 'drivelist/linux.sh'], ['scripts/win32.bat', 'drivelist/win32.bat'], ], }, }; ================================================ FILE: dictionary/ed25519.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/ejs.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/elasticsearch.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/electron.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'index.js': [ 'path.join(__dirname, fs', "path.join(path.dirname(process.execPath), 'electron', fs", ], }, deployFiles: [ ['dist', 'electron/dist', 'directory'], ['../sliced/index.js', 'node_modules/sliced/index.js'], ['../deep-defaults/lib/index.js', 'node_modules/deep-defaults/index.js'], ], }, }; ================================================ FILE: dictionary/emailjs.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/engine.io.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/epoll.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/errorhandler.js ================================================ 'use strict'; module.exports = { pkg: { assets: ['public/**/*'], }, }; ================================================ FILE: dictionary/errors.js ================================================ 'use strict'; module.exports = { pkg: { assets: ['lib/static/*'], }, }; ================================================ FILE: dictionary/eslint.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/rules/*.js', 'lib/formatters/*.js'], }, }; ================================================ FILE: dictionary/etcher-image-write.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/exceljs.js ================================================ 'use strict'; module.exports = { pkg: { assets: [ // TODO look at exceljs and implement as // many __dirname use cases as possible 'lib/**/*.xml', ], patches: { 'lib/stream/xlsx/workbook-writer.js': [ "require.resolve('../../xlsx/xml/theme1.xml')", "require('path').join(__dirname, '../../xlsx/xml/theme1.xml')", ], 'lib/xlsx/xlsx.js': [ "require.resolve('./xml/theme1.xml')", "require('path').join(__dirname, './xml/theme1.xml')", ], }, }, }; ================================================ FILE: dictionary/exiftool.exe.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'index.js': [ "path.join(__dirname, 'vendor', 'exiftool.exe')", "path.join(path.dirname(process.execPath), 'exiftool.exe')", ], }, deployFiles: [['vendor/exiftool.exe', 'exiftool.exe']], }, }; ================================================ FILE: dictionary/exiftool.pl.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'index.js': [ "path.join(__dirname, 'vendor', 'exiftool')", "path.join(path.dirname(process.execPath), 'exiftool')", ], }, deployFiles: [['vendor/exiftool', 'exiftool']], }, }; ================================================ FILE: dictionary/express-load.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'lib/express-load.js': [ 'entity = path.resolve(', 'entity = process.pkg.path.resolve(', ], }, }, }; ================================================ FILE: dictionary/express-session.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/express.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'lib/view.js': [ 'path = join(this.root, path)', 'path = process.pkg.path.resolve(this.root, path)', // for 3.x 'loc = resolve(root, name)', 'loc = process.pkg.path.resolve(root, name)', // for 4.x ], }, }, }; ================================================ FILE: dictionary/extender.js ================================================ 'use strict'; module.exports = { // в declare.js грязный хак. // если в тексте(!) функции есть подстрока "super" // (см SUPER_REGEXP), то её надо оборачивать особым // способом (см functionWrapper). поэтому все пакеты, // которые зависят от declare.js - надо проработать. // хотя бы те файлы, функции в которых попадают в // functionWrapper }; ================================================ FILE: dictionary/extsprintf.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/faye-websocket.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/feathers.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/findup-sync.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/floordate.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/fmt.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/formidable.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/fs-extra.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/fsevents.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/geoip-lite.js ================================================ 'use strict'; module.exports = { pkg: { assets: ['data/*'], }, }; ================================================ FILE: dictionary/github.js ================================================ 'use strict'; module.exports = { pkg: { assets: ['lib/routes.json'], }, }; ================================================ FILE: dictionary/gm.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/google-closure-compiler-java.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'index.js': [ "require.resolve('./compiler.jar')", "require('path').join(require('path').dirname(process.execPath), 'compiler/compiler.jar')", ], }, deployFiles: [['compiler.jar', 'compiler/compiler.jar']], }, }; ================================================ FILE: dictionary/google-closure-compiler.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'lib/node/closure-compiler.js': [ "require.resolve('../../compiler.jar')", "require('path').join(require('path').dirname(process.execPath), 'compiler/compiler.jar')", ], }, deployFiles: [['compiler.jar', 'compiler/compiler.jar']], }, }; ================================================ FILE: dictionary/googleapis.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['apis/**/*.js'], }, }; ================================================ FILE: dictionary/got.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/graceful-fs.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'graceful-fs.js': [ { do: 'prepend' }, 'if ((function() {\n' + " var version = require('./package.json').version;\n" + " var major = parseInt(version.split('.')[0]);\n" + ' if (major < 4) {\n' + " module.exports = require('fs');\n" + ' return true;\n' + ' }\n' + '})()) return;\n', ], }, }, }; ================================================ FILE: dictionary/grpc.js ================================================ 'use strict'; module.exports = { pkg: { files: [ // suppress because hundreds of // C++ files go inside executable ], assets: ['etc/*.pem', 'deps/grpc/etc/*.pem'], }, }; ================================================ FILE: dictionary/gulp.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/hap-nodejs.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/heapdump.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/hoek.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/homebridge.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/http-proxy.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/http-server.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/image-size.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/indexof.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/inquirer.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/j.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'j.js': [ "require('xl'+'sx')", "require('xlsx')", "require('xl'+'sjs')", "require('xlsjs')", "require('ha'+'rb')", "require('harb')", ], }, }, }; ================================================ FILE: dictionary/jade.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/jsdom.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/json-stringify-date.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/json-stringify-safe.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/jsonwebtoken.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/kerberos.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/knex.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/**/*.js'], }, }; ================================================ FILE: dictionary/later.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['later.js'], }, }; ================================================ FILE: dictionary/level.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/leveldown.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'binding.js': ['__dirname', "require('path').dirname(process.execPath)"], }, deployFiles: [['prebuilds', 'prebuilds', 'directory']], }, }; ================================================ FILE: dictionary/levelup.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/liftoff.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'index.js': [ 'resolve.sync(this.moduleName, {basedir: configBase || cwd, paths: paths})', 'resolve.sync(this.moduleName, {basedir: configBase || require.main.filename, paths: paths})', ], }, }, }; ================================================ FILE: dictionary/lodash.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/log4js.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/appenders/*.js'], }, }; ================================================ FILE: dictionary/logform.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['*.js'], }, }; ================================================ FILE: dictionary/machinepack-urls.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['machines/*.js'], }, }; ================================================ FILE: dictionary/markdown.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/mdns.js ================================================ 'use strict'; module.exports = { // хоть bindings и объявлен в // dependencies, но не используется }; ================================================ FILE: dictionary/method-override.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/microjob.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'dist/worker-pool.js': [ 'error.stack = message.error.stack;', 'error.stack = message.error.stack;\n' + 'if (error.stack.indexOf("SyntaxError") >= 0) {' + 'error.stack = "Pkg: Try to specify your ' + "javascript file in 'assets' in config.\\n\" + error.stack;" + '};', ], }, }, }; ================================================ FILE: dictionary/mime-types.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/mime.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/minimatch.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/minstache.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/module-deps.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/moment-timezone.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/moment.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['locale/*.js'], }, }; ================================================ FILE: dictionary/mongodb-core.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'lib/error.js': [ 'return err;', 'if (err.message.indexOf("SyntaxError") >= 0) {' + 'err.message = "Pkg: Try to specify your ' + "javascript file in 'assets' in config. \" + err.message;" + '};\n' + 'return err;', 'if (Error.captureStackTrace) {', 'if (this.message.indexOf("SyntaxError") >= 0) {' + 'this.message = "Pkg: Try to specify your ' + "javascript file in 'assets' in config. \" + this.message;" + '};\n' + 'if (Error.captureStackTrace) {', ], }, }, }; ================================================ FILE: dictionary/mongodb.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/mongodb/**/*.js'], }, }; ================================================ FILE: dictionary/mongoose.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/drivers/node-mongodb-native/*.js'], }, }; ================================================ FILE: dictionary/mongoskin.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/**/*.js'], }, }; ================================================ FILE: dictionary/ms.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/msgpack.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/multer.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/muri.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/native-or-bluebird.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/natives.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/nconf.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/nconf/stores/*.js'], }, }; ================================================ FILE: dictionary/nedb.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/negotiator.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/*.js'], }, }; ================================================ FILE: dictionary/newrelic.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/nib.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/nightmare.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'lib/nightmare.js': [ "path.join(__dirname, 'runner.js')", "path.join(path.dirname(process.execPath), 'nightmare/runner.js')", ], }, deployFiles: [ ['lib/runner.js', 'nightmare/runner.js'], ['lib/frame-manager.js', 'nightmare/frame-manager.js'], ['lib/ipc.js', 'nightmare/ipc.js'], ['lib/preload.js', 'nightmare/preload.js'], ], }, }; ================================================ FILE: dictionary/node-forge.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['js/*.js', 'lib/*.js'], }, }; ================================================ FILE: dictionary/node-libcurl.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/node-notifier.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'notifiers/balloon.js': [ "__dirname, '../vendor/notifu/notifu'", "path.dirname(process.execPath), 'notifier/notifu'", ], 'notifiers/notificationcenter.js': [ "__dirname,\n '../vendor/terminal-notifier.app/Contents/MacOS/terminal-notifier'", "path.dirname(process.execPath), 'notifier/terminal-notifier'", ], 'notifiers/toaster.js': [ "__dirname, '../vendor/snoreToast/snoretoast'", "path.dirname(process.execPath), 'notifier/snoretoast'", ], }, deployFiles: [ ['vendor/notifu/notifu.exe', 'notifier/notifu.exe'], ['vendor/notifu/notifu64.exe', 'notifier/notifu64.exe'], [ 'vendor/terminal-notifier.app/Contents/MacOS/terminal-notifier', 'notifier/terminal-notifier', ], ['vendor/snoreToast/snoretoast-x64.exe', 'notifier/snoretoast-x64.exe'], ['vendor/snoreToast/snoretoast-x86.exe', 'notifier/snoretoast-x86.exe'], ], }, }; ================================================ FILE: dictionary/node-pre-gyp.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/*.js'], }, }; ================================================ FILE: dictionary/node-redis-pubsub.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/node-sass.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/node-uuid.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/node-xlsx.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/node-zookeeper-client.js ================================================ 'use strict'; module.exports = { pkg: { assets: ['lib/jute/specification.json'], }, }; ================================================ FILE: dictionary/nodegit.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['dist/**/*.js'], }, }; ================================================ FILE: dictionary/nodemailer-sendmail-transport.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/nodemailer.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/npm-registry-client.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/**/*.js'], }, }; ================================================ FILE: dictionary/npm.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/*.js'], }, }; ================================================ FILE: dictionary/nssocket.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/oauth2orize.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/**/*.js'], }, }; ================================================ FILE: dictionary/octobat.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/open.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'index.js': [ "path.join(__dirname, 'xdg-open')", "path.join(path.dirname(process.execPath), 'xdg-open')", ], }, deployFiles: [['xdg-open', 'xdg-open']], }, }; ================================================ FILE: dictionary/opn.js ================================================ 'use strict'; // compatibility with 'open' module.exports = require('./open.js'); ================================================ FILE: dictionary/optimist.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/passport-local.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/passport.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/pg-cursor.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/pg-query-stream.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/pg-types.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/arrayParser.js'], }, }; ================================================ FILE: dictionary/pg.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/**/*.js'], }, }; ================================================ FILE: dictionary/pg.js.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/**/*.js'], }, }; ================================================ FILE: dictionary/pgpass.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/helper.js'], }, }; ================================================ FILE: dictionary/phantom.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'lib/phantom.js': [ "__dirname + '/shim/index.js'", "_path2.default.join(_path2.default.dirname(process.execPath), 'phantom/index.js')", ], }, deployFiles: [ ['lib/shim/index.js', 'phantom/index.js'], [ 'lib/shim/function_bind_polyfill.js', 'phantom/function_bind_polyfill.js', ], ], }, }; ================================================ FILE: dictionary/phantomjs-prebuilt.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'lib/phantomjs.js': [ '__dirname, location.location', "path.dirname(process.execPath), 'phantom', path.basename(location.location)", ], }, deployFiles: [ ['lib/phantom/bin/phantomjs', 'phantom/phantomjs'], ['lib/phantom/bin/phantomjs.exe', 'phantom/phantomjs.exe'], ], }, }; ================================================ FILE: dictionary/pkginfo.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/pm2.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/ProcessContainerFork.js'], }, }; ================================================ FILE: dictionary/pmx.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/pouchdb.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/primus-emitter.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/primus-spark-latency.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/primus.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/publicsuffixlist.js ================================================ 'use strict'; module.exports = { dependencies: { gulp: undefined, 'gulp-di': undefined, 'gulp-istanbul': undefined, 'gulp-jshint': undefined, 'gulp-mocha': undefined, mocha: undefined, }, pkg: { assets: ['effective_tld_names.dat'], }, }; ================================================ FILE: dictionary/pug.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/punt.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/puppeteer.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'utils/ChromiumDownloader.js': [ "path.join(__dirname, '..', '.local-chromium')", "path.join(path.dirname(process.execPath), 'puppeteer')", ], }, deployFiles: [['.local-chromium', 'puppeteer', 'directory']], }, }; ================================================ FILE: dictionary/pwd.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/q.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/raven.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/rc.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'lib/utils.js': [ 'process.cwd()', "require('path').dirname(require.main.filename)", ], }, }, }; ================================================ FILE: dictionary/readable-stream.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/rechoir.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/redis-parser.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/redis.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/regression.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/reload.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/reload-server.js'], }, }; ================================================ FILE: dictionary/request.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/require-uncached.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/require_optional.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/s3.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/safe_datejs.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/sails.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/**/*.js'], patches: { 'lib/hooks/moduleloader/index.js': [ "require('coffee-script/register')", '', ], 'lib/app/configuration/index.js': [ 'hook = require(hookBundled);', 'hook = require(hookBundled);' + // force to take the whole package "require('sails-hook-sockets');", ], 'lib/hooks/grunt/index.js': [ 'var child = ChildProcess.fork(', '\n' + "sails.log.warn('*******************************************************************');\n" + "sails.log.warn('** Pkg: Grunt hook is temporarily disabled in pkg-ed app **');\n" + "sails.log.warn('** Instead it should be run before compilation to prepare files **');\n" + "sails.log.warn('*******************************************************************');\n" + "sails.emit('hook:grunt:done');\n" + 'return cb_afterTaskStarted();(', ], 'lib/hooks/orm/backwards-compatibility/upgrade-datastore.js': [ 'if (!fs.existsSync(modulePath)) {', 'try { require(modulePath); } catch (e) {', ], }, }, }; ================================================ FILE: dictionary/sax.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/scrypt.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/semver.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/sequelize.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/**/*.js'], }, }; ================================================ FILE: dictionary/serialport.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/sha3.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/sharp.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/*.js'], deployFiles: [ ['build/Release', 'sharp/build/Release', 'directory'], ['vendor/lib', 'sharp/vendor/lib', 'directory'], ], }, }; ================================================ FILE: dictionary/shelljs.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['src/*.js'], }, }; ================================================ FILE: dictionary/sinon.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/socket.io-client.js ================================================ 'use strict'; module.exports = { pkg: { scripts: [ 'lib/**/*.js', // for 0.9.17 ], assets: [ 'socket.io.js', 'dist/**/*', // for 0.9.17 ], }, }; ================================================ FILE: dictionary/socket.io.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'lib/index.js': [ "require.resolve('socket.io-client/dist/socket.io.js.map')", "require.resolve('socket.io-client/dist/socket.io.js.map', 'must-exclude')", ], }, }, }; ================================================ FILE: dictionary/sqip.js ================================================ 'use strict'; /** * primitive Binaries must be installed on the system. * e.g. go get -u github.com/fogleman/primitive */ module.exports = {}; ================================================ FILE: dictionary/sqlite3.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/steam-crypto.js ================================================ 'use strict'; module.exports = { pkg: { assets: ['public.pub'], }, }; ================================================ FILE: dictionary/steam-resources.js ================================================ 'use strict'; module.exports = { pkg: { assets: ['steam_language/**/*'], patches: { 'steam_language_parser/index.js': [ 'process.chdir', '// process.chdir', "'steammsg.steamd'", "require('path').join(__dirname, '../steam_language', 'steammsg.steamd')", ], 'steam_language_parser/parser/token_analyzer.js': [ 'text.value', "require('path').join(__dirname, '../../steam_language', text.value)", ], }, }, }; ================================================ FILE: dictionary/steam.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/stripe-webhook-middleware.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/stripe.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/strong-globalize.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/stylus.js ================================================ 'use strict'; module.exports = { pkg: { assets: ['lib/**/*.styl'], log: function (log, opts) { log.warn( 'Add { paths: [ __dirname ] } to ' + 'stylus options to resolve imports', [opts.packagePath] ); }, }, }; ================================================ FILE: dictionary/supervisor.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/svgo.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/**/*.js', 'plugins/*.js'], assets: ['.svgo.yml'], }, }; ================================================ FILE: dictionary/tabtab.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/tesseract.js.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['src/worker-script/node/index.js'], }, }; ================================================ FILE: dictionary/throng.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/time.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/tinify.js ================================================ 'use strict'; module.exports = { pkg: { assets: ['lib/data/cacert.pem'], }, }; ================================================ FILE: dictionary/tiny-worker.js ================================================ 'use strict'; module.exports = { pkg: { assets: ['lib/noop.js'], }, }; ================================================ FILE: dictionary/tmp.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/transformers.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/uglify-js.js ================================================ 'use strict'; module.exports = { pkg: { // assets, not scripts because of custom // load_global (readFileSync + runInContext) assets: ['lib/**/*.js', 'tools/*.js'], }, }; ================================================ FILE: dictionary/umd.js ================================================ 'use strict'; module.exports = { pkg: { assets: [ 'template.js', // for 2.1.0 ], patches: { 'index.js': [ "var rfile = require('rfile');", 'var rfile = function(f) { ' + "require('fs').readFileSync(" + // for 2.1.0 'require.resolve(f)' + '); ' + '};', ], }, }, }; ================================================ FILE: dictionary/underscore.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/union.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/update-notifier.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/usage.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/providers/*.js'], }, }; ================================================ FILE: dictionary/v8flags.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'index.js': [ "execFile(process.execPath, ['--v8-options'],", "execFile(process.execPath, ['--v8-options'], " + "{ env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS' } },", ], }, }, }; ================================================ FILE: dictionary/verror.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/voc.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/webdriverio.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['build/**/*.js'], }, }; ================================================ FILE: dictionary/winston-uber.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/winston/transports/*.js'], }, }; ================================================ FILE: dictionary/winston.js ================================================ 'use strict'; module.exports = { pkg: { scripts: ['lib/winston/transports/*.js'], }, }; ================================================ FILE: dictionary/ws.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/xlsx.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'xlsx.js': [ "require('js'+'zip')", "require('jszip')", "require('./js'+'zip')", "require('./jszip')", "require('./od' + 's')", "require('./ods')", ], }, }, }; ================================================ FILE: dictionary/xml2js.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/yargs.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: dictionary/zeromq.js ================================================ 'use strict'; module.exports = { pkg: { patches: { 'lib/native.js': [ 'path.join(__dirname, "..")', 'path.dirname(process.execPath)', ], }, deployFiles: [['prebuilds', 'prebuilds', 'directory']], }, }; ================================================ FILE: examples/.eslintrc.json ================================================ { "parserOptions": { "sourceType": "script" }, "rules": { "no-path-concat": "off", "no-var": "off" } } ================================================ FILE: examples/express/index.js ================================================ 'use strict'; var express = require('express'); var app = express(); var Server = require('http').Server; var server = new Server(app); server.listen(8080); // __dirname is used here along with package.json.pkg.assets // see https://github.com/zeit/pkg#config and // https://github.com/zeit/pkg#snapshot-filesystem app.use('/', express.static(__dirname + '/views')); app.get('/', function (req, res) { res.sendFile(__dirname + '/views/index.html'); }); ================================================ FILE: examples/express/package.json ================================================ { "name": "express-example", "license": "ISC", "bin": "index.js", "dependencies": { "express": "4.15.2" }, "pkg": { "assets": [ "views/**/*" ], "targets": [ "node8" ] } } ================================================ FILE: examples/express/readme.md ================================================ # Express-Example > This example illustrates using `pkg` on a simple Express based app ## Instructions 1. Run `npm install` 2. Run `pkg .` That's it! ## Post Success Notes - Upon success, `pkg` will create an executable named "express-example". This file can be found at the root of the example project directory. - To see the app in action, run the executable then navigate to http://localhost:8080/ in your browser. ================================================ FILE: examples/express/views/index.html ================================================ Hello, world! ================================================ FILE: examples/express/views/lib/sakura.css ================================================ /* Sakura.css v1.0.0 * ================ * Minimal css theme. * Project: https://github.com/oxalorg/sakura */ /* Body */ html { font-size: 62.5%; font-family: serif; } body { font-size: 1.8rem; line-height: 1.618; max-width: 38em; margin: auto; color: #4a4a4a; background-color: #f9f9f9; padding: 13px; } @media (max-width: 684px) { body { font-size: 1.53rem; } } @media (max-width: 382px) { body { font-size: 1.35rem; } } h1, h2, h3, h4, h5, h6 { line-height: 1.1; font-family: Verdana, Geneva, sans-serif; font-weight: 700; overflow-wrap: break-word; word-wrap: break-word; -ms-word-break: break-all; word-break: break-word; -ms-hyphens: auto; -moz-hyphens: auto; -webkit-hyphens: auto; hyphens: auto; } h1 { font-size: 2.35em; } h2 { font-size: 2em; } h3 { font-size: 1.75em; } h4 { font-size: 1.5em; } h5 { font-size: 1.25em; } h6 { font-size: 1em; } small, sub, sup { font-size: 75%; } hr { border-color: #2c8898; } a { text-decoration: none; color: #2c8898; } a:hover { color: #982c61; border-bottom: 2px solid #4a4a4a; } ul { padding-left: 1.4em; } li { margin-bottom: 0.4em; } blockquote { font-style: italic; margin-left: 1.5em; padding-left: 1em; border-left: 3px solid #2c8898; } img { max-width: 100%; } /* Pre and Code */ pre { background-color: #f1f1f1; display: block; padding: 1em; overflow-x: auto; } code { font-size: 0.9em; padding: 0 0.5em; background-color: #f1f1f1; white-space: pre-wrap; } pre > code { padding: 0; background-color: transparent; white-space: pre; } /* Tables */ table { text-align: justify; width: 100%; border-collapse: collapse; } td, th { padding: 0.5em; border-bottom: 1px solid #f1f1f1; } /* Buttons, forms and input */ input, textarea { border: 1px solid #4a4a4a; } input:focus, textarea:focus { border: 1px solid #2c8898; } textarea { width: 100%; } .button, button, input[type='submit'], input[type='reset'], input[type='button'] { display: inline-block; padding: 5px 10px; text-align: center; text-decoration: none; white-space: nowrap; background-color: #2c8898; color: #f9f9f9; border-radius: 1px; border: 1px solid #2c8898; cursor: pointer; box-sizing: border-box; } .button[disabled], button[disabled], input[type='submit'][disabled], input[type='reset'][disabled], input[type='button'][disabled] { cursor: default; opacity: 0.5; } .button:focus, .button:hover, button:focus, button:hover, input[type='submit']:focus, input[type='submit']:hover, input[type='reset']:focus, input[type='reset']:hover, input[type='button']:focus, input[type='button']:hover { background-color: #982c61; border-color: #982c61; color: #f9f9f9; outline: 0; } textarea, select, input[type] { color: #4a4a4a; padding: 6px 10px; /* The 6px vertically centers text on FF, ignored by Webkit */ margin-bottom: 10px; background-color: #f1f1f1; border: 1px solid #f1f1f1; border-radius: 4px; box-shadow: none; box-sizing: border-box; } textarea:focus, select:focus, input[type]:focus { border: 1px solid #2c8898; outline: 0; } label, legend, fieldset { display: block; margin-bottom: 0.5rem; font-weight: 600; } ================================================ FILE: lib/bin.ts ================================================ #!/usr/bin/env node import { exec } from './index'; import { log } from './log'; async function main() { if (process.env.CHDIR && process.env.CHDIR !== process.cwd()) { // allow to override cwd by CHDIR env var // https://github.com/resin-io/etcher/pull/1713 process.chdir(process.env.CHDIR); } await exec(process.argv.slice(2)); } main().catch((error) => { if (!error.wasReported) log.error(error); process.exit(2); }); ================================================ FILE: lib/chmod.ts ================================================ import { chmod, stat } from 'fs-extra'; export async function plusx(file: string) { const s = await stat(file); const newMode = s.mode | 64 | 8 | 1; if (s.mode === newMode) { return; } const base8 = newMode.toString(8).slice(-3); await chmod(file, base8); } ================================================ FILE: lib/common.ts ================================================ import assert from 'assert'; import fs from 'fs'; import path from 'path'; export const STORE_BLOB = 0; export const STORE_CONTENT = 1; export const STORE_LINKS = 2; export const STORE_STAT = 3; export const ALIAS_AS_RELATIVE = 0; // require("./file.js") // file or directory export const ALIAS_AS_RESOLVABLE = 1; // require("package") const win32 = process.platform === 'win32'; const hasURL = typeof URL !== 'undefined'; function uppercaseDriveLetter(f: string) { if (f.slice(1, 3) !== ':\\') return f; return f[0].toUpperCase() + f.slice(1); } function removeTrailingSlashes(f: string) { if (f === '/') { return f; // dont remove from "/" } if (f.slice(1) === ':\\') { return f; // dont remove from "D:\" } let last = f.length - 1; while (true) { const char = f.charAt(last); if (char === '\\') { f = f.slice(0, -1); last -= 1; } else if (char === '/') { f = f.slice(0, -1); last -= 1; } else { break; } } return f; } const isUrl = (p: unknown): p is URL => hasURL && p instanceof URL; function pathToString(p: string | URL | Buffer, win: boolean): string { let result: string; if (Buffer.isBuffer(p)) { result = p.toString(); } else if (isUrl(p)) { result = win ? p.pathname.replace(/^\//, '') : p.pathname; } else { result = p; } return result; } export function isRootPath(p: string | URL | Buffer) { let file = pathToString(p, false); if (file === '.') { file = path.resolve(file); } return path.dirname(file) === p; } export function normalizePath(f: string | URL | Buffer) { let file = pathToString(f, win32); if (!/^.:$/.test(file)) { file = path.normalize(file); } // 'c:' -> 'c:.' if (win32) { file = uppercaseDriveLetter(file); } return removeTrailingSlashes(file); } export function isPackageJson(file: string) { return path.basename(file) === 'package.json'; } export function isDotJS(file: string) { return path.extname(file) === '.js'; } export function isDotJSON(file: string) { return path.extname(file) === '.json'; } export function isDotNODE(file: string) { return path.extname(file) === '.node'; } function replaceSlashes(file: string, slash: string) { if (/^.:\\/.test(file)) { if (slash === '/') { return file.slice(2).replace(/\\/g, '/'); } } else if (/^\//.test(file)) { if (slash === '\\') { return `C:${file.replace(/\//g, '\\')}`; } } return file; } function injectSnapshot(file: string) { if (/^.:\\/.test(file)) { // C:\path\to if (file.length === 3) { // C:\ file = file.slice(0, -1); } // by convention, on windows we use C:\\snapshot return `C:\\snapshot${file.slice(2)}`; } if (/^\//.test(file)) { // /home/user/project if (file.length === 1) { // / file = file.slice(0, -1); } return `/snapshot${file}`; } return file; } function longestCommonLength(s1: string, s2: string) { const length = Math.min(s1.length, s2.length); for (let i = 0; i < length; i += 1) { if (s1.charCodeAt(i) !== s2.charCodeAt(i)) { return i; } } return length; } function withoutNodeModules(file: string) { return file.split(`${path.sep}node_modules${path.sep}`)[0]; } export function retrieveDenominator(files: string[]) { assert(files.length > 0); let s1 = withoutNodeModules(files[0]) + path.sep; for (let i = 1; i < files.length; i += 1) { const s2 = withoutNodeModules(files[i]) + path.sep; s1 = s1.slice(0, longestCommonLength(s1, s2)); } if (s1 === '') { return win32 ? 2 : 0; } return s1.lastIndexOf(path.sep); } export function substituteDenominator(f: string, denominator: number) { const rootLength = win32 ? 2 : 0; return f.slice(0, rootLength) + f.slice(denominator); } export function snapshotify(file: string, slash: string) { return injectSnapshot(replaceSlashes(file, slash)); } export function insideSnapshot(f: Buffer | string | URL) { f = pathToString(f, win32); if (typeof f !== 'string') { return false; } if (win32) { const slice112 = f.slice(1, 12); return ( slice112 === ':\\snapshot\\' || slice112 === ':/snapshot\\' || slice112 === ':\\snapshot/' || slice112 === ':/snapshot/' || slice112 === ':\\snapshot' || slice112 === ':/snapshot' ); } const slice010 = f.slice(0, 10); return slice010 === '/snapshot/' || slice010 === '/snapshot'; } export function stripSnapshot(f: string) { const file = normalizePath(f); if (/^.:\\snapshot$/.test(file)) { return `${file[0]}:\\**\\`; } if (/^.:\\snapshot\\/.test(file)) { return `${file[0]}:\\**${file.slice(11)}`; } if (/^\/snapshot$/.test(file)) { return '/**/'; } if (/^\/snapshot\//.test(file)) { return `/**${file.slice(9)}`; } return f; // not inside } export function removeUplevels(f: string) { if (win32) { while (true) { if (f.slice(0, 3) === '..\\') { f = f.slice(3); } else if (f === '..') { f = '.'; } else { break; } } return f; } while (true) { if (f.slice(0, 3) === '../') { f = f.slice(3); } else if (f === '..') { f = '.'; } else { break; } } return f; } export function toNormalizedRealPath(requestPath: string) { const file = normalizePath(requestPath); if (fs.existsSync(file)) { return fs.realpathSync(file); } return file; } ================================================ FILE: lib/compress_type.ts ================================================ export enum CompressType { None = 0, GZip = 1, Brotli = 2, } ================================================ FILE: lib/detector.ts ================================================ import * as babelTypes from '@babel/types'; import * as babel from '@babel/parser'; import generate from '@babel/generator'; import { log } from './log'; import { ALIAS_AS_RELATIVE, ALIAS_AS_RESOLVABLE } from './common'; function isLiteral(node: babelTypes.Node): node is babelTypes.Literal { if (node == null) { return false; } if (!node.type.endsWith('Literal')) { return false; } if (node.type === 'TemplateLiteral' && node.expressions.length !== 0) { return false; } return true; } function getLiteralValue(node: babelTypes.Literal) { if (node.type === 'TemplateLiteral') { return node.quasis[0].value.raw; } if (node.type === 'NullLiteral') { throw new Error('Unexpected null in require expression'); } if (node.type === 'RegExpLiteral') { throw new Error('Unexpected regexp in require expression'); } return node.value; } function reconstructSpecifiers( specs: ( | babelTypes.ImportDefaultSpecifier | babelTypes.ImportNamespaceSpecifier | babelTypes.ImportSpecifier )[] ) { if (!specs || !specs.length) { return ''; } const defaults = []; for (const spec of specs) { if (babelTypes.isImportDefaultSpecifier(spec)) { defaults.push(spec.local.name); } } const nonDefaults = []; for (const spec of specs) { if (babelTypes.isImportSpecifier(spec)) { const importedName = babelTypes.isIdentifier(spec.imported) ? spec.imported.name : spec.imported.value; if (spec.local.name === importedName) { nonDefaults.push(spec.local.name); } else { nonDefaults.push(`${importedName} as ${spec.local.name}`); } } } if (nonDefaults.length) { defaults.push(`{ ${nonDefaults.join(', ')} }`); } return defaults.join(', '); } function reconstruct(node: babelTypes.Node) { let v = generate(node, { comments: false }).code.replace(/\n/g, ''); let v2; while (true) { v2 = v.replace(/\[ /g, '[').replace(/ \]/g, ']').replace(/ {2}/g, ' '); if (v2 === v) { break; } v = v2; } return v2; } interface Was { v1: string | number | boolean; v2?: string | number | boolean | null; v3?: string; } function forge(pattern: string, was: Was) { return pattern .replace('{c1}', ', ') .replace('{v1}', `"${was.v1}"`) .replace('{c2}', was.v2 ? ', ' : '') .replace('{v2}', was.v2 ? `"${was.v2}"` : '') .replace('{c3}', was.v3 ? ' from ' : '') .replace('{v3}', was.v3 ? was.v3 : ''); } function valid2(v2?: Was['v2']) { return ( v2 === undefined || v2 === null || v2 === 'must-exclude' || v2 === 'may-exclude' ); } function visitorRequireResolve(n: babelTypes.Node) { if (!babelTypes.isCallExpression(n)) { return null; } if (!babelTypes.isMemberExpression(n.callee)) { return null; } const ci = n.callee.object.type === 'Identifier' && n.callee.object.name === 'require' && n.callee.property.type === 'Identifier' && n.callee.property.name === 'resolve'; if (!ci) { return null; } if (!n.arguments || !isLiteral(n.arguments[0])) { return null; } return { v1: getLiteralValue(n.arguments[0]), v2: isLiteral(n.arguments[1]) ? getLiteralValue(n.arguments[1]) : null, }; } function visitorRequire(n: babelTypes.Node) { if (!babelTypes.isCallExpression(n)) { return null; } if (!babelTypes.isIdentifier(n.callee)) { return null; } if (n.callee.name !== 'require') { return null; } if (!n.arguments || !isLiteral(n.arguments[0])) { return null; } return { v1: getLiteralValue(n.arguments[0]), v2: isLiteral(n.arguments[1]) ? getLiteralValue(n.arguments[1]) : null, }; } function visitorImport(n: babelTypes.Node) { if (!babelTypes.isImportDeclaration(n)) { return null; } return { v1: n.source.value, v3: reconstructSpecifiers(n.specifiers) }; } function visitorPathJoin(n: babelTypes.Node) { if (!babelTypes.isCallExpression(n)) { return null; } if (!babelTypes.isMemberExpression(n.callee)) { return null; } const ci = n.callee.object && n.callee.object.type === 'Identifier' && n.callee.object.name === 'path' && n.callee.property && n.callee.property.type === 'Identifier' && n.callee.property.name === 'join'; if (!ci) { return null; } const dn = n.arguments[0] && n.arguments[0].type === 'Identifier' && n.arguments[0].name === '__dirname'; if (!dn) { return null; } const f = n.arguments && isLiteral(n.arguments[1]) && n.arguments.length === 2; // TODO concat them if (!f) { return null; } return { v1: getLiteralValue(n.arguments[1] as babelTypes.StringLiteral) }; } export function visitorSuccessful(node: babelTypes.Node, test = false) { let was: Was | null = visitorRequireResolve(node); if (was) { if (test) { return forge('require.resolve({v1}{c2}{v2})', was); } if (!valid2(was.v2)) { return null; } return { alias: was.v1, aliasType: ALIAS_AS_RESOLVABLE, mustExclude: was.v2 === 'must-exclude', mayExclude: was.v2 === 'may-exclude', }; } was = visitorRequire(node); if (was) { if (test) { return forge('require({v1}{c2}{v2})', was); } if (!valid2(was.v2)) { return null; } return { alias: was.v1, aliasType: ALIAS_AS_RESOLVABLE, mustExclude: was.v2 === 'must-exclude', mayExclude: was.v2 === 'may-exclude', }; } was = visitorImport(node); if (was) { if (test) { return forge('import {v3}{c3}{v1}', was); } return { alias: was.v1, aliasType: ALIAS_AS_RESOLVABLE }; } was = visitorPathJoin(node); if (was) { if (test) { return forge('path.join(__dirname{c1}{v1})', was); } return { alias: was.v1, aliasType: ALIAS_AS_RELATIVE, mayExclude: false }; } return null; } function nonLiteralRequireResolve(n: babelTypes.Node) { if (!babelTypes.isCallExpression(n)) { return null; } if (!babelTypes.isMemberExpression(n.callee)) { return null; } const ci = n.callee.object.type === 'Identifier' && n.callee.object.name === 'require' && n.callee.property.type === 'Identifier' && n.callee.property.name === 'resolve'; if (!ci) { return null; } if (isLiteral(n.arguments[0])) { return null; } const m = n.arguments[1]; if (!m) { return { v1: reconstruct(n.arguments[0]) }; } if (!isLiteral(n.arguments[1])) { return null; } return { v1: reconstruct(n.arguments[0]), v2: getLiteralValue(n.arguments[1]), }; } function nonLiteralRequire(n: babelTypes.Node) { if (!babelTypes.isCallExpression(n)) { return null; } if (!babelTypes.isIdentifier(n.callee)) { return null; } if (n.callee.name !== 'require') { return null; } if (isLiteral(n.arguments[0])) { return null; } const m = n.arguments[1]; if (!m) { return { v1: reconstruct(n.arguments[0]) }; } if (!isLiteral(n.arguments[1])) { return null; } return { v1: reconstruct(n.arguments[0]), v2: getLiteralValue(n.arguments[1]), }; } export function visitorNonLiteral(n: babelTypes.Node) { const was = nonLiteralRequireResolve(n) || nonLiteralRequire(n); if (was) { if (!valid2(was.v2)) { return null; } return { alias: was.v1, mustExclude: was.v2 === 'must-exclude', mayExclude: was.v2 === 'may-exclude', }; } return null; } function isRequire(n: babelTypes.Node) { if (!babelTypes.isCallExpression(n)) { return null; } if (!babelTypes.isIdentifier(n.callee)) { return null; } if (n.callee.name !== 'require') { return null; } const f = n.arguments && n.arguments[0]; if (!f) { return null; } return { v1: reconstruct(n.arguments[0]) }; } function isRequireResolve(n: babelTypes.Node) { if (!babelTypes.isCallExpression(n)) { return null; } if (!babelTypes.isMemberExpression(n.callee)) { return null; } const ci = n.callee.object.type === 'Identifier' && n.callee.object.name === 'require' && n.callee.property.type === 'Identifier' && n.callee.property.name === 'resolve'; if (!ci) { return null; } const f = n.type === 'CallExpression' && n.arguments && n.arguments[0]; if (!f) { return null; } return { v1: reconstruct(n.arguments[0]) }; } export function visitorMalformed(n: babelTypes.Node) { const was = isRequireResolve(n) || isRequire(n); if (was) { return { alias: was.v1 }; } return null; } export function visitorUseSCWD(n: babelTypes.Node) { if (!babelTypes.isCallExpression(n)) { return null; } if (!babelTypes.isMemberExpression(n.callee)) { return null; } const ci = n.callee.object.type === 'Identifier' && n.callee.object.name === 'path' && n.callee.property.type === 'Identifier' && n.callee.property.name === 'resolve'; if (!ci) { return null; } const was = { v1: n.arguments.map(reconstruct).join(', ') }; if (was) { return { alias: was.v1 }; } return null; } type VisitorFunction = (node: babelTypes.Node, trying?: boolean) => boolean; function traverse(ast: babelTypes.File, visitor: VisitorFunction) { // modified esprima-walk to support // visitor return value and "trying" flag // eslint-disable-next-line @typescript-eslint/no-explicit-any const stack: Array<[any, boolean]> = [[ast, false]]; for (let i = 0; i < stack.length; i += 1) { const item = stack[i]; const [node] = item; if (node) { const trying = item[1] || babelTypes.isTryStatement(node); if (visitor(node, trying)) { for (const key in node) { if (node[key as keyof babelTypes.File]) { const child = node[key as keyof babelTypes.File]; if (child instanceof Array) { for (let j = 0; j < child.length; j += 1) { stack.push([child[j], trying]); } } else if (child && typeof child.type === 'string') { stack.push([child, trying]); } } } } } } } export function parse(body: string) { return babel.parse(body, { allowImportExportEverywhere: true, allowReturnOutsideFunction: true, }); } export function detect(body: string, visitor: VisitorFunction) { let json; try { json = parse(body); } catch (error) { log.warn(`Babel parse has failed: ${(error as Error).message}`); } if (!json) { return; } traverse(json, visitor); } ================================================ FILE: lib/fabricator.ts ================================================ import { spawn, ChildProcessByStdio } from 'child_process'; import { Readable, Writable } from 'stream'; import { log } from './log'; import { Target } from './types'; const script = ` var vm = require('vm'); var module = require('module'); var stdin = Buffer.alloc(0); process.stdin.on('data', function (data) { stdin = Buffer.concat([ stdin, data ]); if (stdin.length >= 4) { var sizeOfSnap = stdin.readInt32LE(0); if (stdin.length >= 4 + sizeOfSnap + 4) { var sizeOfBody = stdin.readInt32LE(4 + sizeOfSnap); if (stdin.length >= 4 + sizeOfSnap + 4 + sizeOfBody) { var snap = stdin.toString('utf8', 4, 4 + sizeOfSnap); var body = Buffer.alloc(sizeOfBody); var startOfBody = 4 + sizeOfSnap + 4; stdin.copy(body, 0, startOfBody, startOfBody + sizeOfBody); stdin = Buffer.alloc(0); var code = module.wrap(body); var s = new vm.Script(code, { filename: snap, produceCachedData: true, sourceless: true }); if (!s.cachedDataProduced) { console.error('Pkg: Cached data not produced.'); process.exit(2); } var h = Buffer.alloc(4); var b = s.cachedData; h.writeInt32LE(b.length, 0); process.stdout.write(h); process.stdout.write(b); } } } }); process.stdin.resume(); `; const children: Record< string, ChildProcessByStdio > = {}; export function fabricate( bakes: string[], fabricator: Target, snap: string, body: Buffer, cb: (error?: Error, buffer?: Buffer) => void ) { const activeBakes = bakes.filter((bake) => { // list of bakes that don't influence the bytecode const bake2 = bake.replace(/_/g, '-'); return !['--prof', '--v8-options', '--trace-opt', '--trace-deopt'].includes( bake2 ); }); const cmd = fabricator.binaryPath; const key = JSON.stringify([cmd, activeBakes]); let child = children[key]; if (!child) { const stderr = log.debugMode ? process.stdout : 'ignore'; children[key] = spawn(cmd, activeBakes.concat('-e', script), { stdio: ['pipe', 'pipe', stderr], env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS' }, }); child = children[key]; } function kill() { delete children[key]; child.kill(); } let stdout = Buffer.alloc(0); function onError(error: Error) { // eslint-disable-next-line @typescript-eslint/no-use-before-define removeListeners(); kill(); cb( new Error( `Failed to make bytecode ${fabricator.nodeRange}-${fabricator.arch} for file ${snap} error (${error.message})` ) ); } function onClose(code: number) { // eslint-disable-next-line @typescript-eslint/no-use-before-define removeListeners(); kill(); if (code !== 0) { return cb( new Error( `Failed to make bytecode ${fabricator.nodeRange}-${fabricator.arch} for file ${snap}` ) ); } // eslint-disable-next-line no-console console.log(stdout.toString()); return cb(new Error(`${cmd} closed unexpectedly`)); } function onData(data: Buffer) { stdout = Buffer.concat([stdout, data]); if (stdout.length >= 4) { const sizeOfBlob = stdout.readInt32LE(0); if (stdout.length >= 4 + sizeOfBlob) { const blob = Buffer.alloc(sizeOfBlob); stdout.copy(blob, 0, 4, 4 + sizeOfBlob); // eslint-disable-next-line @typescript-eslint/no-use-before-define removeListeners(); return cb(undefined, blob); } } } function removeListeners() { child.removeListener('error', onError); child.removeListener('close', onClose); child.stdin.removeListener('error', onError); child.stdout.removeListener('error', onError); child.stdout.removeListener('data', onData); } child.on('error', onError); child.on('close', onClose); child.stdin.on('error', onError); child.stdout.on('error', onError); child.stdout.on('data', onData); const h = Buffer.alloc(4); let b = Buffer.from(snap); h.writeInt32LE(b.length, 0); child.stdin.write(h); child.stdin.write(b); b = body; h.writeInt32LE(b.length, 0); child.stdin.write(h); child.stdin.write(b); } export function fabricateTwice( bakes: string[], fabricator: Target, snap: string, body: Buffer, cb: (error?: Error, buffer?: Buffer) => void ) { fabricate(bakes, fabricator, snap, body, (error, buffer) => { // node0 can not produce second time, even if first time produced fine, // probably because of 'filename' cache. also, there are weird cases // when node4 can not compile as well, for example file 'lib/js-yaml/dumper.js' // of package js-yaml@3.9.0 does not get bytecode second time on node4-win-x64 if (error) return fabricate(bakes, fabricator, snap, body, cb); cb(undefined, buffer); }); } export function shutdown() { for (const key in children) { if (children[key]) { const child = children[key]; delete children[key]; child.kill(); } } } ================================================ FILE: lib/follow.ts ================================================ import { sync, SyncOpts } from 'resolve'; import fs from 'fs'; import path from 'path'; import { toNormalizedRealPath } from './common'; import type { PackageJson } from './types'; const PROOF = 'a-proof-that-main-is-captured.js'; function parentDirectoriesContain(parent: string, directory: string) { let currentParent = parent; while (true) { if (currentParent === directory) { return true; } const newParent = path.dirname(currentParent); if (newParent === currentParent) { return false; } currentParent = newParent; } } interface FollowOptions extends Pick { ignoreFile?: string; catchReadFile?: (file: string) => void; catchPackageFilter?: (config: PackageJson, base: string, dir: string) => void; } export function follow(x: string, opts: FollowOptions) { // TODO async version return new Promise((resolve) => { resolve( sync(x, { basedir: opts.basedir, extensions: opts.extensions, isFile: (file) => { if ( opts.ignoreFile && path.join(path.dirname(opts.ignoreFile), PROOF) === file ) { return true; } let stat; try { stat = fs.statSync(file); } catch (e) { const ex = e as NodeJS.ErrnoException; if (ex && (ex.code === 'ENOENT' || ex.code === 'ENOTDIR')) return false; throw ex; } return stat.isFile() || stat.isFIFO(); }, isDirectory: (directory) => { if ( opts.ignoreFile && parentDirectoriesContain(opts.ignoreFile, directory) ) { return false; } let stat; try { stat = fs.statSync(directory); } catch (e) { const ex = e as NodeJS.ErrnoException; if (ex && (ex.code === 'ENOENT' || ex.code === 'ENOTDIR')) { return false; } throw ex; } return stat.isDirectory(); }, readFileSync: (file) => { if (opts.ignoreFile && opts.ignoreFile === file) { return Buffer.from(`{"main":"${PROOF}"}`); } if (opts.catchReadFile) { opts.catchReadFile(file); } return fs.readFileSync(file); }, packageFilter: (config, base, dir) => { if (opts.catchPackageFilter) { opts.catchPackageFilter(config, base, dir); } return config; }, /** function to synchronously resolve a potential symlink to its real path */ // realpathSync?: (file: string) => string; realpathSync: (file) => { const file2 = toNormalizedRealPath(file); return file2; }, }) ); }); } ================================================ FILE: lib/help.ts ================================================ import chalk from 'chalk'; export default function help() { // eslint-disable-next-line no-console console.log(` ${chalk.bold('pkg')} [options] ${chalk.dim('Options:')} -h, --help output usage information -v, --version output pkg version -t, --targets comma-separated list of targets (see examples) -c, --config package.json or any json file with top-level config --options bake v8 options into executable to run with them on -o, --output output file name or template for several files --out-path path to save output one or more executables -d, --debug show more information during packaging process [off] -b, --build don't download prebuilt base binaries, build them --public speed up and disclose the sources of top-level project --public-packages force specified packages to be considered public --no-bytecode skip bytecode generation and include source files as plain js --no-native-build skip native addons build --no-dict comma-separated list of packages names to ignore dictionaries. Use --no-dict * to disable all dictionaries -C, --compress [default=None] compression algorithm = Brotli or GZip ${chalk.dim('Examples:')} ${chalk.gray('–')} Makes executables for Linux, macOS and Windows ${chalk.cyan('$ pkg index.js')} ${chalk.gray('–')} Takes package.json from cwd and follows 'bin' entry ${chalk.cyan('$ pkg .')} ${chalk.gray('–')} Makes executable for particular target machine ${chalk.cyan('$ pkg -t node14-win-arm64 index.js')} ${chalk.gray('–')} Makes executables for target machines of your choice ${chalk.cyan('$ pkg -t node16-linux,node18-linux,node18-win index.js')} ${chalk.gray( '–' )} Bakes '--expose-gc' and '--max-heap-size=34' into executable ${chalk.cyan('$ pkg --options "expose-gc,max-heap-size=34" index.js')} ${chalk.gray('–')} Consider packageA and packageB to be public ${chalk.cyan('$ pkg --public-packages "packageA,packageB" index.js')} ${chalk.gray('–')} Consider all packages to be public ${chalk.cyan('$ pkg --public-packages "*" index.js')} ${chalk.gray('–')} Bakes '--expose-gc' into executable ${chalk.cyan('$ pkg --options expose-gc index.js')} ${chalk.gray( '–' )} reduce size of the data packed inside the executable with GZip ${chalk.cyan('$ pkg --compress GZip index.js')} `); } ================================================ FILE: lib/index.ts ================================================ /* eslint-disable require-atomic-updates */ import assert from 'assert'; import { existsSync, mkdirp, readFile, remove, stat, readFileSync, writeFileSync, copyFileSync, } from 'fs-extra'; import minimist from 'minimist'; import { need, system } from 'pkg-fetch'; import path from 'path'; import { log, wasReported } from './log'; import help from './help'; import { isPackageJson } from './common'; import packer from './packer'; import { plusx } from './chmod'; import producer from './producer'; import refine from './refiner'; import { shutdown } from './fabricator'; import walk, { Marker, WalkerParams } from './walker'; import { Target, NodeTarget, SymLinks } from './types'; import { CompressType } from './compress_type'; import { patchMachOExecutable, signMachOExecutable } from './mach-o'; const { version } = JSON.parse( readFileSync(path.join(__dirname, '../package.json'), 'utf-8') ); function isConfiguration(file: string) { return isPackageJson(file) || file.endsWith('.config.json'); } // http://www.openwall.com/lists/musl/2012/12/08/4 const { hostArch, hostPlatform, isValidNodeRange, knownArchs, knownPlatforms, toFancyArch, toFancyPlatform, } = system; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const hostNodeRange = `node${process.version.match(/^v(\d+)/)![1]}`; function parseTargets(items: string[]): NodeTarget[] { // [ 'node6-macos-x64', 'node6-linux-x64' ] const targets: NodeTarget[] = []; for (const item of items) { const target = { nodeRange: hostNodeRange, platform: hostPlatform, arch: hostArch, }; if (item !== 'host') { for (const token of item.split('-')) { if (!token) { continue; } if (isValidNodeRange(token)) { target.nodeRange = token; continue; } const p = toFancyPlatform(token); if (knownPlatforms.indexOf(p) >= 0) { target.platform = p; continue; } const a = toFancyArch(token); if (knownArchs.indexOf(a) >= 0) { target.arch = a; continue; } throw wasReported(`Unknown token '${token}' in '${item}'`); } } targets.push(target as NodeTarget); } return targets; } function stringifyTarget(target: NodeTarget) { const { nodeRange, platform, arch } = target; return `${nodeRange}-${platform}-${arch}`; } interface DifferentResult { nodeRange?: boolean; platform?: boolean; arch?: boolean; } function differentParts(targets: NodeTarget[]): DifferentResult { const nodeRanges: Record = {}; const platforms: Record = {}; const archs: Record = {}; for (const target of targets) { nodeRanges[target.nodeRange] = true; platforms[target.platform] = true; archs[target.arch] = true; } const result: DifferentResult = {}; if (Object.keys(nodeRanges).length > 1) { result.nodeRange = true; } if (Object.keys(platforms).length > 1) { result.platform = true; } if (Object.keys(archs).length > 1) { result.arch = true; } return result; } function stringifyTargetForOutput( output: string, target: NodeTarget, different: DifferentResult ) { const a = [output]; if (different.nodeRange) { a.push(target.nodeRange); } if (different.platform) { a.push(target.platform); } if (different.arch) { a.push(target.arch); } return a.join('-'); } function fabricatorForTarget({ nodeRange, arch }: NodeTarget) { let fabPlatform = hostPlatform; if ( hostArch !== arch && (hostPlatform === 'linux' || hostPlatform === 'alpine') ) { // With linuxstatic, it is possible to generate bytecode for different // arch with simple QEMU configuration instead of the entire sysroot. fabPlatform = 'linuxstatic'; } return { nodeRange, platform: fabPlatform, arch, }; } const dryRunResults: Record = {}; async function needWithDryRun({ forceBuild, nodeRange, platform, arch, }: NodeTarget) { const result = await need({ dryRun: true, forceBuild, nodeRange, platform, arch, }); assert(['exists', 'fetched', 'built'].indexOf(result) >= 0); dryRunResults[result] = true; } const targetsCache: Record = {}; async function needViaCache(target: NodeTarget) { const s = stringifyTarget(target); let c = targetsCache[s]; if (c) { return c; } const { forceBuild, nodeRange, platform, arch } = target; c = await need({ forceBuild, nodeRange, platform, arch, }); targetsCache[s] = c; return c; } export async function exec(argv2: string[]) { const argv = minimist(argv2, { boolean: [ 'b', 'build', 'bytecode', 'native-build', 'd', 'debug', 'h', 'help', 'public', 'v', 'version', 'signature', ], string: [ '_', 'c', 'config', 'o', 'options', 'output', 'outdir', 'out-dir', 'out-path', 'public-packages', 'no-dict', 't', 'target', 'targets', 'C', 'compress', ], default: { bytecode: true, 'native-build': true, signature: true }, }); if (argv.h || argv.help) { help(); return; } // version if (argv.v || argv.version) { // eslint-disable-next-line no-console console.log(version); return; } log.info(`pkg@${version}`); // debug log.debugMode = argv.d || argv.debug; // forceBuild const forceBuild = argv.b || argv.build; // doCompress const algo = argv.C || argv.compress || 'None'; let doCompress: CompressType = CompressType.None; switch (algo.toLowerCase()) { case 'brotli': case 'br': doCompress = CompressType.Brotli; break; case 'gzip': case 'gz': doCompress = CompressType.GZip; break; case 'none': break; default: throw wasReported( `Invalid compression algorithm ${algo} ( should be None, Brotli or Gzip)` ); } if (doCompress !== CompressType.None) { // eslint-disable-next-line no-console console.log('compression: ', CompressType[doCompress]); } // _ if (!argv._.length) { throw wasReported('Entry file/directory is expected', [ 'Pass --help to see usage information', ]); } if (argv._.length > 1) { throw wasReported('Not more than one entry file/directory is expected'); } // input let input = path.resolve(argv._[0]); if (!existsSync(input)) { throw wasReported('Input file does not exist', [input]); } if ((await stat(input)).isDirectory()) { input = path.join(input, 'package.json'); if (!existsSync(input)) { throw wasReported('Input file does not exist', [input]); } } // inputJson let inputJson; let inputJsonName; if (isConfiguration(input)) { inputJson = JSON.parse(await readFile(input, 'utf-8')); inputJsonName = inputJson.name; if (inputJsonName) { inputJsonName = inputJsonName.split('/').pop(); // @org/foo } } // inputBin let inputBin; if (inputJson) { let { bin } = inputJson; if (bin) { if (typeof bin === 'object') { if (bin[inputJsonName]) { bin = bin[inputJsonName]; } else { bin = bin[Object.keys(bin)[0]]; // TODO multiple inputs to pkg them all? } } inputBin = path.resolve(path.dirname(input), bin); if (!existsSync(inputBin)) { throw wasReported( 'Bin file does not exist (taken from package.json ' + "'bin' property)", [inputBin] ); } } } if (inputJson && !inputBin) { throw wasReported("Property 'bin' does not exist in", [input]); } // inputFin const inputFin = inputBin || input; // config let config = argv.c || argv.config; if (inputJson && config) { throw wasReported("Specify either 'package.json' or config. Not both"); } // configJson let configJson; if (config) { config = path.resolve(config); if (!existsSync(config)) { throw wasReported('Config file does not exist', [config]); } // eslint-disable-next-line import/no-dynamic-require, global-require configJson = require(config); // may be either json or js if ( !configJson.name && !configJson.files && !configJson.dependencies && !configJson.pkg ) { // package.json not detected configJson = { pkg: configJson }; } } // output, outputPath let output = argv.o || argv.output; let outputPath = argv['out-path'] || argv.outdir || argv['out-dir']; let autoOutput = false; if (output && outputPath) { throw wasReported("Specify either 'output' or 'out-path'. Not both"); } if (!output) { let name; if (inputJson) { name = inputJsonName; if (!name) { throw wasReported("Property 'name' does not exist in", [argv._[0]]); } } else if (configJson) { name = configJson.name; } if (!name) { name = path.basename(inputFin); } if (!outputPath) { if (inputJson && inputJson.pkg) { outputPath = inputJson.pkg.outputPath; } else if (configJson && configJson.pkg) { outputPath = configJson.pkg.outputPath; } outputPath = outputPath || ''; } autoOutput = true; const ext = path.extname(name); output = name.slice(0, -ext.length || undefined); output = path.resolve(outputPath || '', output); } else { output = path.resolve(output); } // targets const sTargets = argv.t || argv.target || argv.targets || ''; if (typeof sTargets !== 'string') { throw wasReported(`Something is wrong near ${JSON.stringify(sTargets)}`); } let targets = parseTargets( sTargets.split(',').filter((t) => t) ) as unknown as Array>; if (!targets.length) { let jsonTargets; if (inputJson && inputJson.pkg) { jsonTargets = inputJson.pkg.targets; } else if (configJson && configJson.pkg) { jsonTargets = configJson.pkg.targets; } if (jsonTargets) { targets = parseTargets(jsonTargets); } } if (!targets.length) { if (!autoOutput) { targets = parseTargets(['host']); assert(targets.length === 1); } else { targets = parseTargets(['linux', 'macos', 'win']); } log.info( 'Targets not specified. Assuming:', `${targets.map((t) => stringifyTarget(t)).join(', ')}` ); } // differentParts const different = differentParts(targets); // targets[].output for (const target of targets) { let file; if (targets.length === 1) { file = output; } else { file = stringifyTargetForOutput(output, target, different); } if (target.platform === 'win' && path.extname(file) !== '.exe') { file += '.exe'; } target.output = file; } // bakes const bakes = ((argv.options || '') as string) .split(',') .filter((bake) => bake) .map((bake) => `--${bake}`); // check if input is going // to be overwritten by output for (const target of targets) { if (target.output === inputFin) { if (autoOutput) { target.output += `-${target.platform}`; } else { throw wasReported('Refusing to overwrite input file', [inputFin]); } } } // fetch targets const { bytecode } = argv; const nativeBuild = argv['native-build']; for (const target of targets) { target.forceBuild = forceBuild; await needWithDryRun(target); target.fabricator = fabricatorForTarget(target) as Target; if (bytecode) { await needWithDryRun({ ...target.fabricator, forceBuild, }); } } if (dryRunResults.fetched && !dryRunResults.built) { log.info('Fetching base Node.js binaries to PKG_CACHE_PATH'); } for (const target of targets) { target.binaryPath = await needViaCache(target); const f = target.fabricator; if (f && bytecode) { f.binaryPath = await needViaCache(f as NodeTarget); if (f.platform === 'macos') { // ad-hoc sign the base binary temporarily to generate bytecode // due to the new mandatory signing requirement const signedBinaryPath = `${f.binaryPath}-signed`; await remove(signedBinaryPath); copyFileSync(f.binaryPath, signedBinaryPath); try { signMachOExecutable(signedBinaryPath); } catch { throw wasReported('Cannot generate bytecode', [ 'pkg fails to run "codesign" utility. Due to the mandatory signing', 'requirement of macOS, executables must be signed. Please ensure the', 'utility is installed and properly configured.', ]); } f.binaryPath = signedBinaryPath; } if (f.platform !== 'win') { await plusx(f.binaryPath); } } } // marker let marker: Marker; if (configJson) { marker = { config: configJson, base: path.dirname(config), configPath: config, }; } else { marker = { config: inputJson || {}, // not `inputBin` because only `input` base: path.dirname(input), // is the place for `inputJson` configPath: input, }; } marker.toplevel = true; // public const params: WalkerParams = {}; if (argv.public) { params.publicToplevel = true; } if (argv['public-packages']) { params.publicPackages = argv['public-packages'].split(','); if (params.publicPackages?.indexOf('*') !== -1) { params.publicPackages = ['*']; } } if (argv['no-dict']) { params.noDictionary = argv['no-dict'].split(','); if (params.noDictionary?.indexOf('*') !== -1) { params.noDictionary = ['*']; } } // records let records; let entrypoint = inputFin; let symLinks: SymLinks; const addition = isConfiguration(input) ? input : undefined; const walkResult = await walk(marker, entrypoint, addition, params); entrypoint = walkResult.entrypoint; records = walkResult.records; symLinks = walkResult.symLinks; const refineResult = refine(records, entrypoint, symLinks); entrypoint = refineResult.entrypoint; records = refineResult.records; symLinks = refineResult.symLinks; const backpack = packer({ records, entrypoint, bytecode, symLinks }); log.debug('Targets:', JSON.stringify(targets, null, 2)); for (const target of targets) { if (target.output && existsSync(target.output)) { if ((await stat(target.output)).isFile()) { await remove(target.output); } else { throw wasReported('Refusing to overwrite non-file output', [ target.output, ]); } } else if (target.output) { await mkdirp(path.dirname(target.output)); } await producer({ backpack, bakes, slash: target.platform === 'win' ? '\\' : '/', target: target as Target, symLinks, doCompress, nativeBuild, }); if (target.platform !== 'win' && target.output) { if (argv.signature && target.platform === 'macos') { // patch executable to allow code signing const buf = patchMachOExecutable(readFileSync(target.output)); writeFileSync(target.output, buf); try { // sign executable ad-hoc to workaround the new mandatory signing requirement // users can always replace the signature if necessary signMachOExecutable(target.output); } catch { if (target.arch === 'arm64') { log.warn('Unable to sign the macOS executable', [ 'Due to the mandatory code signing requirement, before the', 'executable is distributed to end users, it must be signed.', 'Otherwise, it will be immediately killed by kernel on launch.', 'An ad-hoc signature is sufficient.', 'To do that, run pkg on a Mac, or transfer the executable to a Mac', 'and run "codesign --sign - ", or (if you use Linux)', 'install "ldid" utility to PATH and then run pkg again', ]); } } } await plusx(target.output); } } shutdown(); } ================================================ FILE: lib/log.js ================================================ export { log, wasReported } from 'pkg-fetch/lib-es5/log'; ================================================ FILE: lib/mach-o.ts ================================================ import { execFileSync } from 'child_process'; function parseCStr(buf: Buffer) { for (let i = 0; i < buf.length; i += 1) { if (buf[i] === 0) { return buf.slice(0, i).toString(); } } } function patchCommand(type: number, buf: Buffer, file: Buffer) { // segment_64 if (type === 0x19) { const name = parseCStr(buf.slice(0, 16)); if (name === '__LINKEDIT') { const fileoff = buf.readBigUInt64LE(32); const vmsizePatched = BigInt(file.length) - fileoff; const filesizePatched = vmsizePatched; buf.writeBigUInt64LE(vmsizePatched, 24); buf.writeBigUInt64LE(filesizePatched, 40); } } // symtab if (type === 0x2) { const stroff = buf.readUInt32LE(8); const strsizePatched = file.length - stroff; buf.writeUInt32LE(strsizePatched, 12); } } function patchMachOExecutable(file: Buffer) { const align = 8; const hsize = 32; const ncmds = file.readUInt32LE(16); const buf = file.slice(hsize); for (let offset = 0, i = 0; i < ncmds; i += 1) { const type = buf.readUInt32LE(offset); offset += 4; const size = buf.readUInt32LE(offset) - 8; offset += 4; patchCommand(type, buf.slice(offset, offset + size), file); offset += size; if (offset & align) { offset += align - (offset & align); } } return file; } function signMachOExecutable(executable: string) { try { execFileSync('codesign', ['-f', '--sign', '-', executable], { stdio: 'inherit', }); } catch { execFileSync('ldid', ['-Cadhoc', '-S', executable], { stdio: 'inherit' }); } } export { patchMachOExecutable, signMachOExecutable }; ================================================ FILE: lib/packer.ts ================================================ /* eslint-disable complexity */ import assert from 'assert'; import fs from 'fs-extra'; import path from 'path'; import { STORE_BLOB, STORE_CONTENT, STORE_LINKS, STORE_STAT, isDotJS, isDotJSON, } from './common'; import { log, wasReported } from './log'; import { FileRecord, FileRecords, SymLinks } from './types'; const { version } = JSON.parse( fs.readFileSync(path.join(__dirname, '../package.json'), 'utf-8') ); const bootstrapText = fs .readFileSync(require.resolve('../prelude/bootstrap.js'), 'utf8') .replace('%VERSION%', version); const commonText = fs.readFileSync(require.resolve('./common'), 'utf8'); const diagnosticText = fs.readFileSync( require.resolve('../prelude/diagnostic.js'), 'utf8' ); function itemsToText(items: T[]) { const len = items.length; return len.toString() + (len % 10 === 1 ? ' item' : ' items'); } function hasAnyStore(record: FileRecord) { // discarded records like native addons for (const store of [STORE_BLOB, STORE_CONTENT, STORE_LINKS, STORE_STAT]) { if (record[store]) return true; } return false; } interface PackerOptions { records: FileRecords; entrypoint: string; bytecode: boolean; symLinks: SymLinks; } export interface Stripe { snap: string; skip?: boolean; store: number; file?: string; buffer?: Buffer; } export default function packer({ records, entrypoint, bytecode, }: PackerOptions) { const stripes: Stripe[] = []; for (const snap in records) { if (records[snap]) { const record = records[snap]; const { file } = record; if (!hasAnyStore(record)) { continue; } assert(record[STORE_STAT], 'packer: no STORE_STAT'); assert( record[STORE_BLOB] || record[STORE_CONTENT] || record[STORE_LINKS] || record[STORE_STAT] ); if (record[STORE_BLOB] && !bytecode) { delete record[STORE_BLOB]; if (!record[STORE_CONTENT]) { // TODO make a test for it? throw wasReported( '--no-bytecode and no source breaks final executable', [ file, 'Please run with "-d" and without "--no-bytecode" first, and make', 'sure that debug log does not contain "was included as bytecode".', ] ); } } for (const store of [ STORE_BLOB, STORE_CONTENT, STORE_LINKS, STORE_STAT, ]) { const value = record[store]; if (!value) { continue; } if (store === STORE_BLOB || store === STORE_CONTENT) { if (record.body === undefined) { stripes.push({ snap, store, file }); } else if (Buffer.isBuffer(record.body)) { stripes.push({ snap, store, buffer: record.body }); } else if (typeof record.body === 'string') { stripes.push({ snap, store, buffer: Buffer.from(record.body) }); } else { assert(false, 'packer: bad STORE_BLOB/STORE_CONTENT'); } } else if (store === STORE_LINKS) { if (Array.isArray(value)) { const dedupedValue = [...new Set(value)]; log.debug('files & folders deduped = ', dedupedValue); const buffer = Buffer.from(JSON.stringify(dedupedValue)); stripes.push({ snap, store, buffer }); } else { assert(false, 'packer: bad STORE_LINKS'); } } else if (store === STORE_STAT) { if (typeof value === 'object') { const newStat = { ...value }; const buffer = Buffer.from(JSON.stringify(newStat)); stripes.push({ snap, store, buffer }); } else { assert(false, 'packer: unknown store'); } } if (record[STORE_CONTENT]) { const disclosed = isDotJS(file) || isDotJSON(file); log.debug( disclosed ? 'The file was included as DISCLOSED code (with sources)' : 'The file was included as asset content', file ); } else if (record[STORE_BLOB]) { log.debug('The file was included as bytecode (no sources)', file); } else if (record[STORE_LINKS]) { const link = record[STORE_LINKS]; log.debug( `The directory files list was included (${itemsToText(link)})`, file ); } } } } const prelude = `return (function (REQUIRE_COMMON, VIRTUAL_FILESYSTEM, DEFAULT_ENTRYPOINT, SYMLINKS, DICT, DOCOMPRESS) { ${bootstrapText}${ log.debugMode ? diagnosticText : '' }\n})(function (exports) {\n${commonText}\n},\n` + `%VIRTUAL_FILESYSTEM%` + `\n,\n` + `%DEFAULT_ENTRYPOINT%` + `\n,\n` + `%SYMLINKS%` + '\n,\n' + '%DICT%' + '\n,\n' + '%DOCOMPRESS%' + `\n);`; return { prelude, entrypoint, stripes }; } ================================================ FILE: lib/producer.ts ================================================ import { createBrotliCompress, createGzip } from 'zlib'; import Multistream from 'multistream'; import assert from 'assert'; import { execFileSync } from 'child_process'; import fs from 'fs-extra'; import intoStream from 'into-stream'; import path from 'path'; import streamMeter from 'stream-meter'; import { Readable } from 'stream'; import { STORE_BLOB, STORE_CONTENT, isDotNODE, snapshotify } from './common'; import { log, wasReported } from './log'; import { fabricateTwice } from './fabricator'; import { platform, SymLinks, Target } from './types'; import { Stripe } from './packer'; import { CompressType } from './compress_type'; interface NotFound { notFound: true; } interface Placeholder { position: number; size: number; padder: string; } type PlaceholderTypes = | 'BAKERY' | 'PAYLOAD_POSITION' | 'PAYLOAD_SIZE' | 'PRELUDE_POSITION' | 'PRELUDE_SIZE'; type PlaceholderMap = Record; function discoverPlaceholder( binaryBuffer: Buffer, searchString: string, padder: string ): Placeholder | NotFound { const placeholder = Buffer.from(searchString); const position = binaryBuffer.indexOf(placeholder); if (position === -1) { return { notFound: true }; } return { position, size: placeholder.length, padder }; } function injectPlaceholder( fd: number, placeholder: Placeholder | NotFound, value: string | number | Buffer, cb: ( err: NodeJS.ErrnoException | null, written: number, buffer: Buffer ) => void ) { if ('notFound' in placeholder) { assert(false, 'Placeholder for not found'); } const { position, size, padder } = placeholder; let stringValue: Buffer = Buffer.from(''); if (typeof value === 'number') { stringValue = Buffer.from(value.toString()); } else if (typeof value === 'string') { stringValue = Buffer.from(value); } else { stringValue = value; } const padding = Buffer.from(padder.repeat(size - stringValue.length)); stringValue = Buffer.concat([stringValue, padding]); fs.write(fd, stringValue, 0, stringValue.length, position, cb); } function discoverPlaceholders(binaryBuffer: Buffer) { return { BAKERY: discoverPlaceholder( binaryBuffer, `\0${'// BAKERY '.repeat(20)}`, '\0' ), PAYLOAD_POSITION: discoverPlaceholder( binaryBuffer, '// PAYLOAD_POSITION //', ' ' ), PAYLOAD_SIZE: discoverPlaceholder(binaryBuffer, '// PAYLOAD_SIZE //', ' '), PRELUDE_POSITION: discoverPlaceholder( binaryBuffer, '// PRELUDE_POSITION //', ' ' ), PRELUDE_SIZE: discoverPlaceholder(binaryBuffer, '// PRELUDE_SIZE //', ' '), }; } function injectPlaceholders( fd: number, placeholders: PlaceholderMap, values: Record, cb: (error?: Error | null) => void ) { injectPlaceholder(fd, placeholders.BAKERY, values.BAKERY, (error) => { if (error) { return cb(error); } injectPlaceholder( fd, placeholders.PAYLOAD_POSITION, values.PAYLOAD_POSITION, (error2) => { if (error2) { return cb(error2); } injectPlaceholder( fd, placeholders.PAYLOAD_SIZE, values.PAYLOAD_SIZE, (error3) => { if (error3) { return cb(error3); } injectPlaceholder( fd, placeholders.PRELUDE_POSITION, values.PRELUDE_POSITION, (error4) => { if (error4) { return cb(error4); } injectPlaceholder( fd, placeholders.PRELUDE_SIZE, values.PRELUDE_SIZE, cb ); } ); } ); } ); }); } function makeBakeryValueFromBakes(bakes: string[]) { const parts = []; if (bakes.length) { for (let i = 0; i < bakes.length; i += 1) { parts.push(Buffer.from(bakes[i])); parts.push(Buffer.alloc(1)); } parts.push(Buffer.alloc(1)); } return Buffer.concat(parts); } function replaceDollarWise(s: string, sf: string, st: string) { return s.replace(sf, () => st); } function makePreludeBufferFromPrelude(prelude: string) { return Buffer.from( `(function(process, require, console, EXECPATH_FD, PAYLOAD_POSITION, PAYLOAD_SIZE) { ${prelude}\n})` // dont remove \n ); } function findPackageJson(nodeFile: string) { let dir = nodeFile; while (dir !== '/') { dir = path.dirname(dir); if (fs.existsSync(path.join(dir, 'package.json'))) { break; } } if (dir === '/') { throw new Error(`package.json not found for "${nodeFile}"`); } return dir; } function nativePrebuildInstall(target: Target, nodeFile: string) { const prebuildInstall = path.join( __dirname, '../node_modules/.bin/prebuild-install' ); const dir = findPackageJson(nodeFile); // parse the target node version from the binaryPath const nodeVersion = path.basename(target.binaryPath).split('-')[1]; if (!/^v[0-9]+\.[0-9]+\.[0-9]+$/.test(nodeVersion)) { throw new Error(`Couldn't find node version, instead got: ${nodeVersion}`); } const nativeFile = `${nodeFile}.${target.platform}.${nodeVersion}`; if (fs.existsSync(nativeFile)) { return nativeFile; } // prebuild-install will overwrite the target .node file, so take a backup if (!fs.existsSync(`${nodeFile}.bak`)) { fs.copyFileSync(nodeFile, `${nodeFile}.bak`); } const napiVersions = JSON.parse( fs.readFileSync(path.join(dir, 'package.json'), { encoding: 'utf-8' }) )?.binary?.napi_versions; const options = [ '--platform', platform[target.platform], '--arch', target.arch, ]; if (napiVersions == null) { // TODO: consider target node version and supported n-api version options.push('--target', nodeVersion); } // run prebuild execFileSync(prebuildInstall, options, { cwd: dir }); // move the prebuild to a new name with a platform/version extension fs.copyFileSync(nodeFile, nativeFile); // put the backed up file back fs.moveSync(`${nodeFile}.bak`, nodeFile, { overwrite: true }); return nativeFile; } interface ProducerOptions { backpack: { entrypoint: string; stripes: Stripe[]; prelude: string }; bakes: string[]; slash: string; target: Target; symLinks: SymLinks; doCompress: CompressType; nativeBuild: boolean; } /** * instead of creating a vfs dicionnary with actual path as key * we use a compression mechanism that can reduce significantly * the memory footprint of the vfs in the code. * * without vfs compression: * * vfs = { * "/folder1/folder2/file1.js": {}; * "/folder1/folder2/folder3/file2.js": {}; * "/folder1/folder2/folder3/file3.js": {}; * } * * with compression : * * fileDictionary = { * "folder1": "1", * "folder2": "2", * "file1": "3", * "folder3": "4", * "file2": "5", * "file3": "6", * } * vfs = { * "/1/2/3": {}; * "/1/2/4/5": {}; * "/1/2/4/6": {}; * } * * note: the key is computed in base36 for further compression. */ const fileDictionary: { [key: string]: string } = {}; let counter = 0; function getOrCreateHash(fileOrFolderName: string) { let existingKey = fileDictionary[fileOrFolderName]; if (!existingKey) { const newkey = counter; counter += 1; existingKey = newkey.toString(36); fileDictionary[fileOrFolderName] = existingKey; } return existingKey; } const separator = '/'; function makeKey( doCompression: CompressType, fullpath: string, slash: string ): string { if (doCompression === CompressType.None) return fullpath; return fullpath.split(slash).map(getOrCreateHash).join(separator); } export default function producer({ backpack, bakes, slash, target, symLinks, doCompress, nativeBuild, }: ProducerOptions) { return new Promise((resolve, reject) => { if (!Buffer.alloc) { throw wasReported( 'Your node.js does not have Buffer.alloc. Please upgrade!' ); } const { prelude } = backpack; let { entrypoint, stripes } = backpack; entrypoint = snapshotify(entrypoint, slash); stripes = stripes.slice(); const vfs: Record> = {}; for (const stripe of stripes) { let { snap } = stripe; snap = snapshotify(snap, slash); const vfsKey = makeKey(doCompress, snap, slash); if (!vfs[vfsKey]) vfs[vfsKey] = {}; } const snapshotSymLinks: SymLinks = {}; for (const [key, value] of Object.entries(symLinks)) { const k = snapshotify(key, slash); const v = snapshotify(value, slash); const vfsKey = makeKey(doCompress, k, slash); snapshotSymLinks[vfsKey] = makeKey(doCompress, v, slash); } let meter: streamMeter.StreamMeter; let count = 0; function pipeToNewMeter(s: Readable) { meter = streamMeter(); return s.pipe(meter); } function pipeMayCompressToNewMeter(s: Readable): streamMeter.StreamMeter { if (doCompress === CompressType.GZip) { return pipeToNewMeter(s.pipe(createGzip())); } if (doCompress === CompressType.Brotli) { return pipeToNewMeter(s.pipe(createBrotliCompress())); } return pipeToNewMeter(s); } function next(s: Readable) { count += 1; return pipeToNewMeter(s); } const binaryBuffer = fs.readFileSync(target.binaryPath); const placeholders = discoverPlaceholders(binaryBuffer); let track = 0; let prevStripe: Stripe; let payloadPosition: number; let payloadSize: number; let preludePosition: number; let preludeSize: number; new Multistream((cb) => { if (count === 0) { return cb(null, next(intoStream(binaryBuffer))); } if (count === 1) { payloadPosition = meter.bytes; return cb(null, next(intoStream(Buffer.alloc(0)))); } if (count === 2) { if (prevStripe && !prevStripe.skip) { const { store } = prevStripe; let { snap } = prevStripe; snap = snapshotify(snap, slash); const vfsKey = makeKey(doCompress, snap, slash); vfs[vfsKey][store] = [track, meter.bytes]; track += meter.bytes; } if (stripes.length) { // clone to prevent 'skip' propagate // to other targets, since same stripe // is used for several targets const stripe = { ...(stripes.shift() as Stripe) }; prevStripe = stripe; if (stripe.buffer) { if (stripe.store === STORE_BLOB) { const snap = snapshotify(stripe.snap, slash); return fabricateTwice( bakes, target.fabricator, snap, stripe.buffer, (error, buffer) => { if (error) { log.warn(error.message); stripe.skip = true; return cb(null, intoStream(Buffer.alloc(0))); } cb( null, pipeMayCompressToNewMeter( intoStream(buffer || Buffer.from('')) ) ); } ); } return cb( null, pipeMayCompressToNewMeter(intoStream(stripe.buffer)) ); } if (stripe.file) { if (stripe.file === target.output) { return cb( wasReported( 'Trying to take executable into executable', stripe.file ), null ); } assert.strictEqual(stripe.store, STORE_CONTENT); // others must be buffers from walker if (isDotNODE(stripe.file) && nativeBuild) { try { const platformFile = nativePrebuildInstall(target, stripe.file); if (fs.existsSync(platformFile)) { return cb( null, pipeMayCompressToNewMeter(fs.createReadStream(platformFile)) ); } } catch (err) { log.debug( `prebuild-install failed[${stripe.file}]:`, (err as Error).message ); } } return cb( null, pipeMayCompressToNewMeter(fs.createReadStream(stripe.file)) ); } assert(false, 'producer: bad stripe'); } else { payloadSize = track; preludePosition = payloadPosition + payloadSize; return cb( null, next( intoStream( makePreludeBufferFromPrelude( replaceDollarWise( replaceDollarWise( replaceDollarWise( replaceDollarWise( replaceDollarWise( prelude, '%VIRTUAL_FILESYSTEM%', JSON.stringify(vfs) ), '%DEFAULT_ENTRYPOINT%', JSON.stringify(entrypoint) ), '%SYMLINKS%', JSON.stringify(snapshotSymLinks) ), '%DICT%', JSON.stringify(fileDictionary) ), '%DOCOMPRESS%', JSON.stringify(doCompress) ) ) ) ) ); } } else { return cb(null, null); } }) .on('error', (error) => { reject(error); }) .pipe(fs.createWriteStream(target.output)) .on('error', (error) => { reject(error); }) .on('close', () => { preludeSize = meter.bytes; fs.open(target.output, 'r+', (error, fd) => { if (error) return reject(error); injectPlaceholders( fd, placeholders, { BAKERY: makeBakeryValueFromBakes(bakes), PAYLOAD_POSITION: payloadPosition, PAYLOAD_SIZE: payloadSize, PRELUDE_POSITION: preludePosition, PRELUDE_SIZE: preludeSize, }, (error2) => { if (error2) return reject(error2); fs.close(fd, (error3) => { if (error3) return reject(error3); resolve(); }); } ); }); }); }); } ================================================ FILE: lib/refiner.ts ================================================ import path from 'path'; import chalk from 'chalk'; import { STORE_LINKS, retrieveDenominator, substituteDenominator, } from './common'; import { FileRecords, SymLinks } from './types'; import { log } from './log'; const win32 = process.platform === 'win32'; function hasParent(file: string, records: FileRecords) { const dirname = path.dirname(file); // root directory if (dirname === file) { return false; } return Boolean(records[dirname]); } function purgeTopDirectories(records: FileRecords) { while (true) { let found = false; for (const file in records) { if (records[file]) { const record = records[file]; const links = record[STORE_LINKS]; if (links && links.length === 1) { if (!hasParent(file, records)) { const file2 = path.join(file, links[0]); const record2 = records[file2]; const links2 = record2[STORE_LINKS]; if (links2 && links2.length === 1) { const file3 = path.join(file2, links2[0]); const record3 = records[file3]; const links3 = record3[STORE_LINKS]; if (links3) { delete records[file]; log.debug(chalk.cyan('Deleting record file :', file)); found = true; } } } } } } if (!found) break; } } function denominate( records: FileRecords, entrypoint: string, denominator: number, symLinks: SymLinks ) { const newRecords: FileRecords = {}; const makeSnap = (file: string) => { let snap = substituteDenominator(file, denominator); if (win32) { if (snap.slice(1) === ':') snap += '\\'; } else if (snap === '') { snap = '/'; } return snap; }; for (const file in records) { if (records[file]) { const snap = makeSnap(file); newRecords[snap] = records[file]; } } const tmpSymLinks = symLinks; symLinks = {}; for (const [key, value] of Object.entries(tmpSymLinks)) { const key1 = makeSnap(key); const value1 = makeSnap(value); symLinks[key1] = value1; } return { records: newRecords, entrypoint: substituteDenominator(entrypoint, denominator), symLinks, }; } export default function refiner( records: FileRecords, entrypoint: string, symLinks: SymLinks ) { purgeTopDirectories(records); const denominator = retrieveDenominator(Object.keys(records)); return denominate(records, entrypoint, denominator, symLinks); } ================================================ FILE: lib/types.ts ================================================ import type { log } from './log'; export interface FileRecord { file: string; body?: Buffer | string; // This could be improved a bit. making this stricter opens up a lot of // changes that need to be made throughout the code though // eslint-disable-next-line @typescript-eslint/no-explicit-any [key: number]: any; } export type FileRecords = Record; type License = | string | { type: string; }; export type Patches = Record< string, string & { do: 'erase' | 'prepend' | 'append' }[] >; export type ConfigDictionary = Record< string, { pkg?: { dependencies?: Record; }; dependencies?: Record; } >; export interface PkgOptions { scripts?: string[]; log?: (logger: typeof log, context: Record) => void; assets?: string[]; deployFiles?: string[]; patches?: Patches; dictionary: ConfigDictionary; } export interface PackageJson { name?: string; private?: boolean; licenses?: License; license?: License; main?: string; dependencies?: Record; files?: string[]; pkg?: PkgOptions; } export const platform = { macos: 'darwin', win: 'win32', linux: 'linux', }; export interface NodeTarget { nodeRange: string; arch: string; platform: keyof typeof platform; forceBuild?: boolean; } export interface Target extends NodeTarget { binaryPath: string; output: string; fabricator: Target; } export type SymLinks = Record; ================================================ FILE: lib/walker.ts ================================================ /* eslint-disable require-atomic-updates */ import assert from 'assert'; import fs from 'fs-extra'; import isCore from 'is-core-module'; import globby from 'globby'; import path from 'path'; import chalk from 'chalk'; import { ALIAS_AS_RELATIVE, ALIAS_AS_RESOLVABLE, STORE_BLOB, STORE_CONTENT, STORE_LINKS, STORE_STAT, isDotJS, isDotJSON, isDotNODE, isPackageJson, normalizePath, toNormalizedRealPath, } from './common'; import { follow } from './follow'; import { log, wasReported } from './log'; import * as detector from './detector'; import { ConfigDictionary, FileRecord, FileRecords, Patches, PackageJson, SymLinks, } from './types'; export interface Marker { hasDictionary?: boolean; activated?: boolean; toplevel?: boolean; public?: boolean; hasDeployFiles?: boolean; config?: PackageJson; configPath: string; base: string; } interface Task { file: string; data?: unknown; reason?: string; marker?: Marker; store: number; } interface Derivative { alias: string; mayExclude?: boolean; mustExclude?: boolean; aliasType: number; fromDependencies?: boolean; } // Note: as a developer, you can set the PKG_STRICT_VER variable. // this will turn on some assertion in the walker code below // to assert that each file content/state that we appending // to the virtual file system applies to a real file, // not a symlink. // By default assertion are disabled as they can have a // performance hit. const strictVerify = Boolean(process.env.PKG_STRICT_VER); const win32 = process.platform === 'win32'; function unlikelyJavascript(file: string) { return ['.css', '.html', '.json', '.vue'].includes(path.extname(file)); } function isPublic(config: PackageJson) { if (config.private) { return false; } const { licenses } = config; let { license } = config; if (licenses) { license = licenses; } if (license && !Array.isArray(license)) { license = typeof license === 'string' ? license : license.type; } if (Array.isArray(license)) { license = license.map((c) => String(c.type || c)).join(','); } if (!license) { return false; } if (/^\(/.test(license)) { license = license.slice(1); } if (/\)$/.test(license)) { license = license.slice(0, -1); } license = license.toLowerCase(); const allLicenses = Array.prototype.concat( license.split(' or '), license.split(' and '), license.split('/'), license.split(',') ); let result = false; const foss = [ 'isc', 'mit', 'apache-2.0', 'apache 2.0', 'public domain', 'bsd', 'bsd-2-clause', 'bsd-3-clause', 'wtfpl', 'cc-by-3.0', 'x11', 'artistic-2.0', 'gplv3', 'mpl', 'mplv2.0', 'unlicense', 'apache license 2.0', 'zlib', 'mpl-2.0', 'nasa-1.3', 'apache license, version 2.0', 'lgpl-2.1+', 'cc0-1.0', ]; for (const c of allLicenses) { result = foss.indexOf(c) >= 0; if (result) { break; } } return result; } function upon(p: string, base: string) { if (typeof p !== 'string') { throw wasReported('Config items must be strings. See examples'); } let negate = false; if (p[0] === '!') { p = p.slice(1); negate = true; } p = path.join(base, p); if (win32) { p = p.replace(/\\/g, '/'); } if (negate) { p = `!${p}`; } return p; } function collect(ps: string[]) { return globby.sync(ps, { dot: true }); } function expandFiles(efs: string | string[], base: string) { if (!Array.isArray(efs)) { efs = [efs]; } efs = collect(efs.map((p) => upon(p, base))); return efs; } async function stepRead(record: FileRecord) { if (strictVerify) { assert(record.file === toNormalizedRealPath(record.file)); } let body; try { body = await fs.readFile(record.file); } catch (error) { const exception = error as NodeJS.ErrnoException; log.error(`Cannot read file, ${exception.code}`, record.file); throw wasReported(exception.message); } record.body = body; } function stepStrip(record: FileRecord) { let body = (record.body || '').toString('utf8'); if (/^\ufeff/.test(body)) { body = body.replace(/^\ufeff/, ''); } if (/^#!/.test(body)) { body = body.replace(/^#![^\n]*\n/, '\n'); } record.body = body; } function stepDetect( record: FileRecord, marker: Marker, derivatives: Derivative[] ) { let { body = '' } = record; if (body instanceof Buffer) { body = body.toString(); } try { detector.detect(body, (node, trying) => { const { toplevel } = marker; let d = detector.visitorSuccessful(node) as unknown as Derivative; if (d) { if (d.mustExclude) { return false; } d.mayExclude = d.mayExclude || trying; derivatives.push(d); return false; } d = detector.visitorNonLiteral(node) as unknown as Derivative; if (d) { if (typeof d === 'object' && d.mustExclude) { return false; } const debug = !toplevel || d.mayExclude || trying; const level = debug ? 'debug' : 'warn'; log[level](`Cannot resolve '${d.alias}'`, [ record.file, 'Dynamic require may fail at run time, because the requested file', 'is unknown at compilation time and not included into executable.', "Use a string literal as an argument for 'require', or leave it", "as is and specify the resolved file name in 'scripts' option.", ]); return false; } d = detector.visitorMalformed(node) as unknown as Derivative; if (d) { // there is no 'mustExclude' const debug = !toplevel || trying; const level = debug ? 'debug' : 'warn'; // there is no 'mayExclude' log[level](`Malformed requirement for '${d.alias}'`, [record.file]); return false; } d = detector.visitorUseSCWD(node) as unknown as Derivative; if (d) { // there is no 'mustExclude' const level = 'debug'; // there is no 'mayExclude' log[level](`Path.resolve(${d.alias}) is ambiguous`, [ record.file, "It resolves relatively to 'process.cwd' by default, however", "you may want to use 'path.dirname(require.main.filename)'", ]); return false; } return true; // can i go inside? }); } catch (error) { log.error((error as Error).message, record.file); throw wasReported((error as Error).message); } } function findCommonJunctionPoint(file: string, realFile: string) { // find common denominator => where the link changes while (toNormalizedRealPath(path.dirname(file)) === path.dirname(realFile)) { file = path.dirname(file); realFile = path.dirname(realFile); } return { file, realFile }; } export interface WalkerParams { publicToplevel?: boolean; publicPackages?: string[]; noDictionary?: string[]; } class Walker { private params: WalkerParams; private symLinks: SymLinks; private patches: Patches; private tasks: Task[]; private records: FileRecords; private dictionary: ConfigDictionary; constructor() { this.tasks = []; this.records = {}; this.dictionary = {}; this.patches = {}; this.params = {}; this.symLinks = {}; } appendRecord({ file, store }: Task) { if (this.records[file]) { return; } if ( store === STORE_BLOB || store === STORE_CONTENT || store === STORE_LINKS ) { // make sure we have a real file if (strictVerify) { assert(file === toNormalizedRealPath(file)); } } this.records[file] = { file }; } private append(task: Task) { if (strictVerify) { assert(typeof task.file === 'string'); assert(task.file === normalizePath(task.file)); } this.appendRecord(task); this.tasks.push(task); const what = { [STORE_BLOB]: 'Bytecode of', [STORE_CONTENT]: 'Content of', [STORE_LINKS]: 'Directory', [STORE_STAT]: 'Stat info of', }[task.store]; if (task.reason) { log.debug( `${what} ${task.file} is added to queue. It was required from ${task.reason}` ); } else { log.debug(`${what} ${task.file} is added to queue.`); } } appendSymlink(file: string, realFile: string) { const a = findCommonJunctionPoint(file, realFile); file = a.file; realFile = a.realFile; if (!this.symLinks[file]) { const dn = path.dirname(file); this.appendFileInFolder({ file: dn, store: STORE_LINKS, data: path.basename(file), }); log.debug(`adding symlink ${file} => ${path.relative(file, realFile)}`); this.symLinks[file] = realFile; this.appendStat({ file: realFile, store: STORE_STAT, }); this.appendStat({ file: dn, store: STORE_STAT, }); this.appendStat({ file, store: STORE_STAT, }); } } appendStat(task: Task) { assert(task.store === STORE_STAT); this.append(task); } appendFileInFolder(task: Task) { if (strictVerify) { assert(task.store === STORE_LINKS); assert(typeof task.file === 'string'); } const realFile = toNormalizedRealPath(task.file); if (realFile === task.file) { this.append(task); return; } this.append({ ...task, file: realFile }); this.appendStat({ file: task.file, store: STORE_STAT, }); this.appendStat({ file: path.dirname(task.file), store: STORE_STAT, }); } appendBlobOrContent(task: Task) { if (strictVerify) { assert(task.file === normalizePath(task.file)); } assert(task.store === STORE_BLOB || task.store === STORE_CONTENT); assert(typeof task.file === 'string'); const realFile = toNormalizedRealPath(task.file); if (realFile === task.file) { this.append(task); return; } this.append({ ...task, file: realFile }); this.appendSymlink(task.file, realFile); this.appendStat({ file: task.file, store: STORE_STAT, }); } async appendFilesFromConfig(marker: Marker) { const { config, configPath, base } = marker; const pkgConfig = config?.pkg; if (pkgConfig) { let { scripts } = pkgConfig; if (scripts) { scripts = expandFiles(scripts, base); for (const script of scripts) { const stat = await fs.stat(script); if (stat.isFile()) { if (!isDotJS(script) && !isDotJSON(script) && !isDotNODE(script)) { log.warn("Non-javascript file is specified in 'scripts'.", [ 'Pkg will probably fail to parse. Specify *.js in glob.', script, ]); } this.appendBlobOrContent({ file: normalizePath(script), marker, store: STORE_BLOB, reason: configPath, }); } } } let { assets } = pkgConfig; if (assets) { assets = expandFiles(assets, base); for (const asset of assets) { log.debug(' Adding asset : .... ', asset); const stat = await fs.stat(asset); if (stat.isFile()) { this.appendBlobOrContent({ file: normalizePath(asset), marker, store: STORE_CONTENT, reason: configPath, }); } } } } else if (config) { let { files } = config; if (files) { files = expandFiles(files, base); for (let file of files) { file = normalizePath(file); const stat = await fs.stat(file); if (stat.isFile()) { // 1) remove sources of top-level(!) package 'files' i.e. ship as BLOB // 2) non-source (non-js) files of top-level package are shipped as CONTENT // 3) parsing some js 'files' of non-top-level packages fails, hence all CONTENT if (marker.toplevel) { this.appendBlobOrContent({ file, marker, store: isDotJS(file) ? STORE_BLOB : STORE_CONTENT, reason: configPath, }); } else { this.appendBlobOrContent({ file, marker, store: STORE_CONTENT, reason: configPath, }); } } } } } } async stepActivate(marker: Marker, derivatives: Derivative[]) { if (!marker) { assert(false); } if (marker.activated) { return; } const { config, base } = marker; if (!config) { assert(false); } const { name } = config; if (name) { const d = this.dictionary[name]; if (d) { if ( typeof config.dependencies === 'object' && typeof d.dependencies === 'object' ) { Object.assign(config.dependencies, d.dependencies); delete d.dependencies; } Object.assign(config, d); marker.hasDictionary = true; } } const { dependencies } = config; if (typeof dependencies === 'object') { for (const dependency in dependencies) { // it may be `undefined` - overridden // in dictionary (see publicsuffixlist) if (dependencies[dependency]) { derivatives.push({ alias: dependency, aliasType: ALIAS_AS_RESOLVABLE, fromDependencies: true, }); derivatives.push({ alias: `${dependency}/package.json`, aliasType: ALIAS_AS_RESOLVABLE, fromDependencies: true, }); } } } const pkgConfig = config.pkg; if (pkgConfig) { const { patches } = pkgConfig; if (patches) { for (const key in patches) { if (patches[key]) { const p = path.join(base, key); this.patches[p] = patches[key]; } } } const { deployFiles } = pkgConfig; if (deployFiles) { marker.hasDeployFiles = true; for (const deployFile of deployFiles) { const type = deployFile[2] || 'file'; log.warn(`Cannot include ${type} %1 into executable.`, [ `The ${type} must be distributed with executable as %2.`, `%1: ${path.relative( process.cwd(), path.join(base, deployFile[0]) )}`, `%2: path-to-executable/${deployFile[1]}`, ]); } } if (pkgConfig.log) { pkgConfig.log(log, { packagePath: base }); } } await this.appendFilesFromConfig(marker); marker.public = isPublic(config); if (!marker.public && marker.toplevel) { marker.public = this.params.publicToplevel; } if (!marker.public && !marker.toplevel && this.params.publicPackages) { marker.public = this.params.publicPackages[0] === '*' || (!!name && this.params.publicPackages.indexOf(name) !== -1); } marker.activated = true; // assert no further work with config delete marker.config; } hasPatch(record: FileRecord) { const patch = this.patches[record.file]; if (!patch) { return; } return true; } stepPatch(record: FileRecord) { const patch = this.patches[record.file]; if (!patch) { return; } let body = (record.body || '').toString('utf8'); for (let i = 0; i < patch.length; i += 2) { if (typeof patch[i] === 'object') { if (patch[i].do === 'erase') { body = patch[i + 1]; } else if (patch[i].do === 'prepend') { body = patch[i + 1] + body; } else if (patch[i].do === 'append') { body += patch[i + 1]; } } else if (typeof patch[i] === 'string') { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions // function escapeRegExp const esc = patch[i].replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const regexp = new RegExp(esc, 'g'); body = body.replace(regexp, patch[i + 1]); } } record.body = body; } async stepDerivatives_ALIAS_AS_RELATIVE( record: FileRecord, marker: Marker, derivative: Derivative ) { const file = normalizePath( path.join(path.dirname(record.file), derivative.alias) ); let stat; try { stat = await fs.stat(file); } catch (error) { const { toplevel } = marker; const exception = error as NodeJS.ErrnoException; const debug = !toplevel && exception.code === 'ENOENT'; const level = debug ? 'debug' : 'warn'; log[level](`Cannot stat, ${exception.code}`, [ file, `The file was required from '${record.file}'`, ]); } if (stat && stat.isFile()) { this.appendBlobOrContent({ file, marker, store: STORE_CONTENT, reason: record.file, }); } } async stepDerivatives_ALIAS_AS_RESOLVABLE( record: FileRecord, marker: Marker, derivative: Derivative ) { const newPackages: { packageJson: string; marker?: Marker }[] = []; const catchReadFile = (file: string) => { assert(isPackageJson(file), `walker: ${file} must be package.json`); newPackages.push({ packageJson: file }); }; const catchPackageFilter = (config: PackageJson, base: string) => { const newPackage = newPackages[newPackages.length - 1]; newPackage.marker = { config, configPath: newPackage.packageJson, base }; }; let newFile = ''; let failure: Error | undefined; const basedir = path.dirname(record.file); try { newFile = await follow(derivative.alias, { basedir, // default is extensions: ['.js'], but // it is not enough because 'typos.json' // is not taken in require('./typos') // in 'normalize-package-data/lib/fixer.js' extensions: ['.js', '.json', '.node'], catchReadFile, catchPackageFilter, }); } catch (error) { failure = error as Error; } if (failure) { const { toplevel } = marker; const mainNotFound = newPackages.length > 0 && !newPackages[0].marker?.config?.main; const debug = !toplevel || derivative.mayExclude || (mainNotFound && derivative.fromDependencies); const level = debug ? 'debug' : 'warn'; if (mainNotFound) { const message = "Entry 'main' not found in %1"; log[level](message, [ `%1: ${newPackages[0].packageJson}`, `%2: ${record.file}`, ]); } else { log[level](`${chalk.yellow(failure.message)} in ${record.file}`); } return; } let newPackageForNewRecords; for (const newPackage of newPackages) { let newFile2; try { newFile2 = await follow(derivative.alias, { basedir: path.dirname(record.file), extensions: ['.js', '.json', '.node'], ignoreFile: newPackage.packageJson, }); if (strictVerify) { assert(newFile2 === normalizePath(newFile2)); } } catch (_) { // not setting is enough } if (newFile2 !== newFile) { newPackageForNewRecords = newPackage; break; } } if (newPackageForNewRecords) { if (strictVerify) { assert( newPackageForNewRecords.packageJson === normalizePath(newPackageForNewRecords.packageJson) ); } this.appendBlobOrContent({ file: newPackageForNewRecords.packageJson, marker: newPackageForNewRecords.marker, store: STORE_CONTENT, reason: record.file, }); } this.appendBlobOrContent({ file: newFile, marker: newPackageForNewRecords ? newPackageForNewRecords.marker : marker, store: STORE_BLOB, reason: record.file, }); } async stepDerivatives( record: FileRecord, marker: Marker, derivatives: Derivative[] ) { for (const derivative of derivatives) { // TODO: actually use the target node version if (isCore(derivative.alias, '99.0.0')) continue; switch (derivative.aliasType) { case ALIAS_AS_RELATIVE: await this.stepDerivatives_ALIAS_AS_RELATIVE( record, marker, derivative ); break; case ALIAS_AS_RESOLVABLE: await this.stepDerivatives_ALIAS_AS_RESOLVABLE( record, marker, derivative ); break; default: assert(false, `walker: unknown aliasType ${derivative.aliasType}`); } } } async step_STORE_ANY(record: FileRecord, marker: Marker, store: number) { if (strictVerify) { assert(record.file === toNormalizedRealPath(record.file)); } if (record[store] !== undefined) return; record[store] = false; // default is discard this.appendStat({ file: record.file, store: STORE_STAT, }); const derivatives1: Derivative[] = []; await this.stepActivate(marker, derivatives1); await this.stepDerivatives(record, marker, derivatives1); if (store === STORE_BLOB) { if (unlikelyJavascript(record.file) || isDotNODE(record.file)) { this.appendBlobOrContent({ file: record.file, marker, store: STORE_CONTENT, }); return; // discard } if (marker.public || marker.hasDictionary) { this.appendBlobOrContent({ file: record.file, marker, store: STORE_CONTENT, }); } } if (store === STORE_BLOB || this.hasPatch(record)) { if (!record.body) { await stepRead(record); this.stepPatch(record); if (store === STORE_BLOB) { stepStrip(record); } } if (store === STORE_BLOB) { const derivatives2: Derivative[] = []; stepDetect(record, marker, derivatives2); await this.stepDerivatives(record, marker, derivatives2); } } record[store] = true; } step_STORE_LINKS(record: FileRecord, data: unknown) { if (strictVerify) { assert( record.file === toNormalizedRealPath(record.file), ' expecting real file !!!' ); } if (record[STORE_LINKS]) { record[STORE_LINKS].push(data); return; } record[STORE_LINKS] = [data]; if (record[STORE_STAT]) { return; } this.appendStat({ file: record.file, store: STORE_STAT, }); } async step_STORE_STAT(record: FileRecord) { if (record[STORE_STAT]) return; const realPath = toNormalizedRealPath(record.file); if (realPath !== record.file) { this.appendStat({ file: realPath, store: STORE_STAT, }); } try { const valueStat = await fs.stat(record.file); const value = { mode: valueStat.mode, size: valueStat.isFile() ? valueStat.size : 0, isFileValue: valueStat.isFile(), isDirectoryValue: valueStat.isDirectory(), isSocketValue: valueStat.isSocket(), isSymbolicLinkValue: valueStat.isSymbolicLink(), }; record[STORE_STAT] = value; } catch (error) { const exception = error as NodeJS.ErrnoException; log.error(`Cannot stat, ${exception.code}`, record.file); throw wasReported(exception.message); } if (path.dirname(record.file) !== record.file) { // root directory this.appendFileInFolder({ file: path.dirname(record.file), store: STORE_LINKS, data: path.basename(record.file), }); } } async step(task: Task) { const { file, store, data } = task; const record = this.records[file]; switch (store) { case STORE_BLOB: case STORE_CONTENT: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion await this.step_STORE_ANY(record, task.marker!, store); break; case STORE_LINKS: this.step_STORE_LINKS(record, data); break; case STORE_STAT: await this.step_STORE_STAT(record); break; default: assert(false, `walker: unknown store ${store}`); } } async readDictionary(marker: Marker) { if (this.params.noDictionary?.[0] === '*') { return; } const dd = path.join(__dirname, '../dictionary'); const files = await fs.readdir(dd); for (const file of files) { if (/\.js$/.test(file)) { const name = file.slice(0, -3); if (this.params.noDictionary?.includes(file)) { continue; } // eslint-disable-next-line import/no-dynamic-require, global-require, @typescript-eslint/no-var-requires const config = require(path.join(dd, file)); this.dictionary[name] = config; } } const pkgConfig = marker.config?.pkg; if (pkgConfig) { const { dictionary } = pkgConfig; if (dictionary) { for (const name in dictionary) { if (dictionary[name]) { this.dictionary[name] = { pkg: dictionary[name] }; } } } } } async start( marker: Marker, entrypoint: string, addition: string | undefined, params: WalkerParams ) { this.params = params; this.symLinks = {}; await this.readDictionary(marker); entrypoint = normalizePath(entrypoint); this.appendBlobOrContent({ file: entrypoint, marker, store: STORE_BLOB, }); if (addition) { addition = normalizePath(addition); this.appendBlobOrContent({ file: addition, marker, store: STORE_CONTENT, }); } const { tasks } = this; for (let i = 0; i < tasks.length; i += 1) { // NO MULTIPLE WORKERS! THIS WILL LEAD TO NON-DETERMINISTIC // ORDER. one-by-one fifo is the only way to iterate tasks await this.step(tasks[i]); } return { symLinks: this.symLinks, records: this.records, entrypoint: normalizePath(entrypoint), }; } } export default async function walker(...args: Parameters) { const w = new Walker(); return w.start(...args); } ================================================ FILE: package.json ================================================ { "name": "pkg", "version": "5.8.1", "description": "Package your Node.js project into an executable", "main": "lib-es5/index.js", "license": "MIT", "repository": "vercel/pkg", "types": "lib-es5/index.d.ts", "bin": { "pkg": "lib-es5/bin.js" }, "files": [ "lib-es5/*.js", "lib-es5/index.d.ts", "dictionary/*.js", "prelude/*.js" ], "prettier": { "singleQuote": true }, "dependencies": { "@babel/generator": "7.18.2", "@babel/parser": "7.18.4", "@babel/types": "7.19.0", "chalk": "^4.1.2", "fs-extra": "^9.1.0", "globby": "^11.1.0", "into-stream": "^6.0.0", "is-core-module": "2.9.0", "minimist": "^1.2.6", "multistream": "^4.1.0", "pkg-fetch": "3.5.2", "prebuild-install": "7.1.1", "resolve": "^1.22.0", "stream-meter": "^1.0.4" }, "devDependencies": { "@babel/core": "7.18.2", "@types/babel__generator": "7.6.4", "@types/fs-extra": "9.0.13", "@types/is-core-module": "2.2.0", "@types/minimist": "1.2.2", "@types/multistream": "4.1.0", "@types/node": "14.18.20", "@types/resolve": "1.20.2", "@types/stream-meter": "0.0.22", "@typescript-eslint/eslint-plugin": "4.33.0", "@typescript-eslint/parser": "4.33.0", "eslint": "7.32.0", "eslint-config-airbnb-base": "14.2.1", "eslint-config-airbnb-typescript": "12.3.1", "eslint-config-prettier": "8.5.0", "eslint-plugin-import": "2.26.0", "json-stable-stringify": "^1.0.1", "lint-staged": "^10.5.4", "mkdirp": "^1.0.4", "prettier": "2.6.2", "rimraf": "^3.0.2", "simple-git-hooks": ">=2.8.0", "typescript": "4.7.2" }, "scripts": { "clean": "rimraf lib-es5", "build": "npm run clean && tsc", "start": "tsc --watch", "lint": "npm run lint:style && npm run lint:code", "lint:style": "prettier -c \"{lib,prelude,test}/**/*.{ts,js}\"", "lint:code": "eslint lib prelude test", "fix": "npm run lint:style -- -w && npm run lint:code -- --fix", "prepare": "npm run build", "prepublishOnly": "npm run lint", "test": "npm run build && npm run test:18 && npm run test:16 && npm run test:14 && npm run test:host", "test:18": "node test/test.js node18 no-npm", "test:16": "node test/test.js node16 no-npm", "test:14": "node test/test.js node14 no-npm", "test:host": "node test/test.js host only-npm" }, "simple-git-hooks": { "pre-commit": "npx lint-staged" }, "lint-staged": { "*.{js,css,md,json}": "prettier --write" } } ================================================ FILE: prelude/.eslintrc.json ================================================ { "parserOptions": { "sourceType": "script" }, "rules": { "no-var": "off", "vars-on-top": "off" } } ================================================ FILE: prelude/bootstrap.js ================================================ /* eslint-disable import/no-unresolved */ /* eslint-disable global-require */ /* eslint-disable no-underscore-dangle */ /* eslint-disable prefer-rest-params */ /* eslint-disable prefer-spread */ /* global EXECPATH_FD */ /* global PAYLOAD_POSITION */ /* global PAYLOAD_SIZE */ /* global REQUIRE_COMMON */ /* global VIRTUAL_FILESYSTEM */ /* global DEFAULT_ENTRYPOINT */ /* global DICT */ /* global DOCOMPRESS */ /* global SYMLINKS */ 'use strict'; const childProcess = require('child_process'); const { createHash } = require('crypto'); const fs = require('fs'); const { isRegExp } = require('util').types; const Module = require('module'); const path = require('path'); const { promisify, _extend } = require('util'); const { Script } = require('vm'); const { tmpdir } = require('os'); const util = require('util'); const { brotliDecompress, brotliDecompressSync, gunzip, gunzipSync, } = require('zlib'); const common = {}; REQUIRE_COMMON(common); const { STORE_BLOB, STORE_CONTENT, STORE_LINKS, STORE_STAT, isRootPath, normalizePath, insideSnapshot, stripSnapshot, removeUplevels, } = common; let FLAG_ENABLE_PROJECT = false; const NODE_VERSION_MAJOR = process.version.match(/^v(\d+)/)[1] | 0; const NODE_VERSION_MINOR = process.version.match(/^v\d+.(\d+)/)[1] | 0; // ///////////////////////////////////////////////////////////////// // ENTRYPOINT ////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////// // set ENTRYPOINT and ARGV0 here because // they can be altered during process run const ARGV0 = process.argv[0]; const EXECPATH = process.execPath; let ENTRYPOINT = process.argv[1]; if (process.env.PKG_EXECPATH === 'PKG_INVOKE_NODEJS') { return { undoPatch: true }; } if (NODE_VERSION_MAJOR < 12 || require('worker_threads').isMainThread) { if (process.argv[1] !== 'PKG_DUMMY_ENTRYPOINT') { // expand once patchless is introduced, that // will obviously lack any work in node_main.cc throw new Error('PKG_DUMMY_ENTRYPOINT EXPECTED'); } } if (process.env.PKG_EXECPATH === EXECPATH) { process.argv.splice(1, 1); if (process.argv[1] && process.argv[1] !== '-') { // https://github.com/nodejs/node/blob/1a96d83a223ff9f05f7d942fb84440d323f7b596/lib/internal/bootstrap/node.js#L269 process.argv[1] = path.resolve(process.argv[1]); } } else { process.argv[1] = DEFAULT_ENTRYPOINT; } [, ENTRYPOINT = DEFAULT_ENTRYPOINT] = process.argv; delete process.env.PKG_EXECPATH; // ///////////////////////////////////////////////////////////////// // EXECSTAT //////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////// const EXECSTAT = fs.statSync(EXECPATH); EXECSTAT.atimeMs = EXECSTAT.atime.getTime(); EXECSTAT.mtimeMs = EXECSTAT.mtime.getTime(); EXECSTAT.ctimeMs = EXECSTAT.ctime.getTime(); EXECSTAT.birthtimeMs = EXECSTAT.birthtime.getTime(); // ///////////////////////////////////////////////////////////////// // MOUNTPOINTS ///////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////// const mountpoints = []; function insideMountpoint(f) { if (!insideSnapshot(f)) return null; const file = normalizePath(f); const found = mountpoints .map((mountpoint) => { const { interior, exterior } = mountpoint; if (isRegExp(interior) && interior.test(file)) return file.replace(interior, exterior); if (interior === file) return exterior; const left = interior + path.sep; if (file.slice(0, left.length) !== left) return null; return exterior + file.slice(left.length - 1); }) .filter((result) => result); if (found.length >= 2) throw new Error('UNEXPECTED-00'); if (found.length === 0) return null; return found[0]; } function readdirMountpoints(path_) { return mountpoints .filter(({ interior }) => { if (isRegExp(interior)) return interior.test(path_); return path.dirname(interior) === path_; }) .map(({ interior, exterior }) => { if (isRegExp(interior)) return path_.replace(interior, exterior); return path.basename(interior); }); } function translate(f) { const result = insideMountpoint(f); if (!result) throw new Error('UNEXPECTED-05'); return result; } function cloneArgs(args_) { return Array.prototype.slice.call(args_); } function translateNth(args_, index, f) { const args = cloneArgs(args_); args[index] = translate(f); return args; } function createMountpoint(interior, exterior) { // TODO validate mountpoints.push({ interior, exterior }); } const DEFAULT_COPY_CHUNK_SIZE = 10 * 1024 * 1024; // 10 MB function copyInChunks( source, target, chunkSize = DEFAULT_COPY_CHUNK_SIZE, fs_ = fs ) { const sourceFile = fs_.openSync(source, 'r'); const targetFile = fs_.openSync(target, 'w'); let bytesRead = 1; while (bytesRead > 0) { const buffer = Buffer.alloc(chunkSize); bytesRead = fs_.readSync(sourceFile, buffer, 0, chunkSize); fs_.writeSync(targetFile, buffer, 0, bytesRead); } fs_.closeSync(sourceFile); fs_.closeSync(targetFile); } // TODO: replace this with fs.cpSync when we drop Node < 16 function copyFolderRecursiveSync(source, target) { // Build target folder const targetFolder = path.join(target, path.basename(source)); // Check if target folder needs to be created or integrated if (!fs.existsSync(targetFolder)) { fs.mkdirSync(targetFolder); } // Copy if (fs.lstatSync(source).isDirectory()) { const files = fs.readdirSync(source); for (const file of files) { // Build source name const curSource = path.join(source, file); // Call this function recursively as long as source is a directory if (fs.lstatSync(curSource).isDirectory()) { copyFolderRecursiveSync(curSource, targetFolder); } else { // Current source is a file, it must be available on the real filesystem // instead of the virtual snapshot file system to load it by process.dlopen. // // Before we try to copy we do some checks. // See https://github.com/vercel/pkg/issues/1589 for more details. // Build target file name const curTarget = path.join(targetFolder, path.basename(curSource)); if (fs.existsSync(curTarget)) { // Target file already exists, read source and target file... const curSourceContent = fs.readFileSync(curSource, { encoding: 'binary', }); const curTargetContent = fs.readFileSync(curTarget, { encoding: 'binary', }); // ...and calculate checksum from source and target file const curSourceHash = createHash('sha256') .update(curSourceContent) .digest('hex'); const curTargetHash = createHash('sha256') .update(curTargetContent) .digest('hex'); // If checksums are equal then there is nothing to do here // ==> target already exists and is up-to-date if (curSourceHash === curTargetHash) { continue; } } // Target must be copied because it either does not exist or is outdated. // Due to the possibility that mutliple instances of this app start simultaneously, // the copy action might fail. Only one starting instance gets write access. // // We don't catch any error here because it does not make sense to go ahead and to // try to load the file while another instance has not yet finished the copy action. // If the app start fails then the user should try to start the app later again. // Unfortunately, we cannot implement delayed retries ourselves because process.dlopen // is a synchronous function, promises are not supported. fs.copyFileSync(curSource, curTarget); } } } } function createDirRecursively(dir) { if (!fs.existsSync(dir)) { createDirRecursively(path.join(dir, '..')); fs.mkdirSync(dir); } } /* // TODO move to some test createMountpoint("d:\\snapshot\\countly\\plugins-ext", "d:\\deploy\\countly\\v16.02\\plugins-ext"); console.log(insideMountpoint("d:\\snapshot")); console.log(insideMountpoint("d:\\snapshot\\")); console.log(insideMountpoint("d:\\snapshot\\countly")); console.log(insideMountpoint("d:\\snapshot\\countly\\")); console.log(insideMountpoint("d:\\snapshot\\countly\\plugins-ext")); console.log(insideMountpoint("d:\\snapshot\\countly\\plugins-ext\\")); console.log(insideMountpoint("d:\\snapshot\\countly\\plugins-ext\\1234")); console.log(translate("d:\\snapshot\\countly\\plugins-ext")); console.log(translate("d:\\snapshot\\countly\\plugins-ext\\")); console.log(translate("d:\\snapshot\\countly\\plugins-ext\\1234")); console.log(translateNth([], 0, "d:\\snapshot\\countly\\plugins-ext")); console.log(translateNth([], 0, "d:\\snapshot\\countly\\plugins-ext\\")); console.log(translateNth([], 0, "d:\\snapshot\\countly\\plugins-ext\\1234")); console.log(translateNth(["", "r+"], 0, "d:\\snapshot\\countly\\plugins-ext")); console.log(translateNth(["", "rw"], 0, "d:\\snapshot\\countly\\plugins-ext\\")); console.log(translateNth(["", "a+"], 0, "d:\\snapshot\\countly\\plugins-ext\\1234")); */ const dictRev = {}; const separator = '/'; let maxKey = Object.values(DICT).length; function replace(k) { let v = DICT[k]; // we have found a part of a missing file => let record for latter use if (v === undefined) { maxKey += 1; v = maxKey.toString(36); DICT[k] = v; dictRev[v] = k; } return v; } function findVirtualFileSystemKey(path_, slash) { const normalizedPath = normalizePath(path_); if (!DOCOMPRESS) { return normalizedPath; } const a = normalizedPath.split(slash).map(replace).join(separator); return a || normalizedPath; } Object.entries(DICT).forEach(([k, v]) => { dictRev[v] = k; }); function toOriginal(fShort) { if (!DOCOMPRESS) { return fShort; } return fShort .split(separator) .map((x) => dictRev[x]) .join(path.sep); } const symlinksEntries = Object.entries(SYMLINKS); // separator for substitution depends on platform; const sepsep = DOCOMPRESS ? separator : path.sep; function findVirtualFileSystemKeyAndFollowLinks(path_) { let vfsKey = findVirtualFileSystemKey(path_, path.sep); let needToSubstitute = true; while (needToSubstitute) { needToSubstitute = false; for (const [k, v] of symlinksEntries) { if (vfsKey.startsWith(`${k}${sepsep}`) || vfsKey === k) { vfsKey = vfsKey.replace(k, v); needToSubstitute = true; break; } } } return vfsKey; } function realpathFromSnapshot(path_) { const realPath = toOriginal(findVirtualFileSystemKeyAndFollowLinks(path_)); return realPath; } function findVirtualFileSystemEntry(path_) { const vfsKey = findVirtualFileSystemKeyAndFollowLinks(path_); return VIRTUAL_FILESYSTEM[vfsKey]; } // ///////////////////////////////////////////////////////////////// // PROJECT ///////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////// const xpdn = path.dirname(EXECPATH); const maxUplevels = xpdn.split(path.sep).length; function projectToFilesystem(f) { const relatives = []; relatives.push( removeUplevels(path.relative(path.dirname(DEFAULT_ENTRYPOINT), f)) ); if (relatives[0].slice(0, 'node_modules'.length) === 'node_modules') { // one more relative without starting 'node_modules' relatives.push(relatives[0].slice('node_modules'.length + 1)); } const uplevels = []; for (let i = 0, u = ''; i < maxUplevels; i += 1) { uplevels.push(u); u += '/..'; } const results = []; uplevels.forEach((uplevel) => { relatives.forEach((relative) => { results.push(path.join(xpdn, uplevel, relative)); }); }); return results; } function projectToNearby(f) { return path.join(xpdn, path.basename(f)); } function findNativeAddonSyncFreeFromRequire(path_) { if (!insideSnapshot(path_)) throw new Error(`UNEXPECTED-10 ${path_}`); if (path_.slice(-5) !== '.node') return null; // leveldown.node.js // check nearby first to prevent .node tampering const projector = projectToNearby(path_); if (fs.existsSync(projector)) return projector; const projectors = projectToFilesystem(path_); for (let i = 0; i < projectors.length; i += 1) { if (fs.existsSync(projectors[i])) return projectors[i]; } return null; } function findNativeAddonSyncUnderRequire(path_) { if (!FLAG_ENABLE_PROJECT) return null; return findNativeAddonSyncFreeFromRequire(path_); } // ///////////////////////////////////////////////////////////////// // FLOW UTILS ////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////// function asap(cb) { process.nextTick(cb); } function dezalgo(cb) { if (!cb) return cb; let sync = true; asap(() => { sync = false; }); return function zalgoSafe() { const args = arguments; if (sync) { asap(() => { cb.apply(undefined, args); }); } else { cb.apply(undefined, args); } }; } function rethrow(error, arg) { if (error) throw error; return arg; } // ///////////////////////////////////////////////////////////////// // PAYLOAD ///////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////// if (typeof PAYLOAD_POSITION !== 'number' || typeof PAYLOAD_SIZE !== 'number') { throw new Error('MUST HAVE PAYLOAD'); } function readPayload(buffer, offset, length, position, callback) { fs.read( EXECPATH_FD, buffer, offset, length, PAYLOAD_POSITION + position, callback ); } function readPayloadSync(buffer, offset, length, position) { return fs.readSync( EXECPATH_FD, buffer, offset, length, PAYLOAD_POSITION + position ); } function payloadCopyUni( source, target, targetStart, sourceStart, sourceEnd, cb ) { const cb2 = cb || rethrow; if (sourceStart >= source[1]) return cb2(null, 0); if (sourceEnd >= source[1]) [, sourceEnd] = source; const payloadPos = source[0] + sourceStart; const targetPos = targetStart; const targetEnd = targetStart + sourceEnd - sourceStart; if (cb) { readPayload(target, targetPos, targetEnd - targetPos, payloadPos, cb); } else { return readPayloadSync( target, targetPos, targetEnd - targetPos, payloadPos ); } } function payloadCopyMany(source, target, targetStart, sourceStart, cb) { const payloadPos = source[0] + sourceStart; let targetPos = targetStart; const targetEnd = targetStart + source[1] - sourceStart; readPayload( target, targetPos, targetEnd - targetPos, payloadPos, (error, chunkSize) => { if (error) return cb(error); sourceStart += chunkSize; targetPos += chunkSize; if (chunkSize !== 0 && targetPos < targetEnd) { payloadCopyMany(source, target, targetPos, sourceStart, cb); } else { return cb(); } } ); } function payloadCopyManySync(source, target, targetStart, sourceStart) { let payloadPos = source[0] + sourceStart; let targetPos = targetStart; const targetEnd = targetStart + source[1] - sourceStart; while (true) { const chunkSize = readPayloadSync( target, targetPos, targetEnd - targetPos, payloadPos ); payloadPos += chunkSize; targetPos += chunkSize; if (!(chunkSize !== 0 && targetPos < targetEnd)) break; } } const GZIP = 1; const BROTLI = 2; function payloadFile(pointer, cb) { const target = Buffer.alloc(pointer[1]); payloadCopyMany(pointer, target, 0, 0, (error) => { if (error) return cb(error); if (DOCOMPRESS === GZIP) { gunzip(target, (error2, target2) => { if (error2) return cb(error2); cb(null, target2); }); } else if (DOCOMPRESS === BROTLI) { brotliDecompress(target, (error2, target2) => { if (error2) return cb(error2); cb(null, target2); }); } else { return cb(null, target); } }); } function payloadFileSync(pointer) { const target = Buffer.alloc(pointer[1]); payloadCopyManySync(pointer, target, 0, 0); if (DOCOMPRESS === GZIP) { const target1 = gunzipSync(target); return target1; } if (DOCOMPRESS === BROTLI) { const target1 = brotliDecompressSync(target); return target1; } return target; } // ///////////////////////////////////////////////////////////////// // SETUP PROCESS /////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////// (() => { process.pkg = {}; process.versions.pkg = '%VERSION%'; process.pkg.mount = createMountpoint; process.pkg.entrypoint = ENTRYPOINT; process.pkg.defaultEntrypoint = DEFAULT_ENTRYPOINT; })(); // ///////////////////////////////////////////////////////////////// // PATH.RESOLVE REPLACEMENT //////////////////////////////////////// // ///////////////////////////////////////////////////////////////// (() => { process.pkg.path = {}; process.pkg.path.resolve = function resolve() { const args = cloneArgs(arguments); args.unshift(path.dirname(ENTRYPOINT)); return path.resolve.apply(path, args); }; })(); // ///////////////////////////////////////////////////////////////// // PATCH FS //////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////// (() => { const ancestor = { openSync: fs.openSync, open: fs.open, readSync: fs.readSync, read: fs.read, writeSync: fs.writeSync, write: fs.write, closeSync: fs.closeSync, close: fs.close, readFileSync: fs.readFileSync, readFile: fs.readFile, // writeFileSync: fs.writeFileSync, // based on openSync/writeSync/closeSync // writeFile: fs.writeFile, // based on open/write/close readdirSync: fs.readdirSync, readdir: fs.readdir, realpathSync: fs.realpathSync, realpath: fs.realpath, statSync: fs.statSync, stat: fs.stat, lstatSync: fs.lstatSync, lstat: fs.lstat, fstatSync: fs.fstatSync, fstat: fs.fstat, existsSync: fs.existsSync, exists: fs.exists, accessSync: fs.accessSync, access: fs.access, mkdirSync: fs.mkdirSync, mkdir: fs.mkdir, createReadStream: fs.createReadStream, copyFileSync: fs.copyFileSync, copyFile: fs.copyFile, }; ancestor.realpathSync.native = fs.realpathSync; ancestor.realpath.native = fs.realpath; const windows = process.platform === 'win32'; const docks = {}; const ENOTDIR = windows ? 4052 : 20; const ENOENT = windows ? 4058 : 2; const EISDIR = windows ? 4068 : 21; function assertEncoding(encoding) { if (encoding && !Buffer.isEncoding(encoding)) { throw new Error(`Unknown encoding: ${encoding}`); } } function maybeCallback(args) { const cb = args[args.length - 1]; return typeof cb === 'function' ? cb : rethrow; } function error_ENOENT(fileOrDirectory, path_) { const error = new Error( `${fileOrDirectory} '${stripSnapshot(path_)}' ` + `was not included into executable at compilation stage. ` + `Please recompile adding it as asset or script.` ); error.errno = -ENOENT; error.code = 'ENOENT'; error.path = path_; error.pkg = true; return error; } function error_EISDIR(path_) { const error = new Error('EISDIR: illegal operation on a directory, read'); error.errno = -EISDIR; error.code = 'EISDIR'; error.path = path_; error.pkg = true; return error; } function error_ENOTDIR(path_) { const error = new Error(`ENOTDIR: not a directory, scandir '${path_}'`); error.errno = -ENOTDIR; error.code = 'ENOTDIR'; error.path = path_; error.pkg = true; return error; } // /////////////////////////////////////////////////////////////// // open ////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// function removeTemporaryFolderAndContent(folder) { if (!folder) return; if (NODE_VERSION_MAJOR <= 14) { if (NODE_VERSION_MAJOR <= 10) { // folder must be empty for (const f of fs.readdirSync(folder)) { fs.unlinkSync(path.join(folder, f)); } fs.rmdirSync(folder); } else { fs.rmdirSync(folder, { recursive: true }); } } else { fs.rmSync(folder, { recursive: true }); } } const temporaryFiles = {}; const os = require('os'); let tmpFolder = ''; process.on('beforeExit', () => { removeTemporaryFolderAndContent(tmpFolder); }); function deflateSync(snapshotFilename) { if (!tmpFolder) { tmpFolder = fs.mkdtempSync(path.join(os.tmpdir(), 'pkg-')); } const content = fs.readFileSync(snapshotFilename, { encoding: 'binary' }); // content is already unzipped ! const hash = createHash('sha256').update(content).digest('hex'); const fName = path.join(tmpFolder, hash); fs.writeFileSync(fName, content, 'binary'); return fName; } const uncompressExternally = function uncompressExternally(dock) { if (!dock.externalFilename) { const snapshotFilename = dock.path; let t = temporaryFiles[snapshotFilename]; if (!t) { const tmpFile = deflateSync(snapshotFilename); t = { tmpFile }; temporaryFiles[snapshotFilename] = t; } dock.externalFilename = t.tmpFile; } return dock.externalFilename; }; function uncompressExternallyPath(path_) { const entity = findVirtualFileSystemEntry(path_); const dock = { path: path_, entity, position: 0 }; return uncompressExternally(dock); } function uncompressExternallyAndOpen(dock) { const externalFile = uncompressExternally(dock); const fd = fs.openSync(externalFile, 'r'); return fd; } function openFromSnapshot(path_, uncompress, cb) { const cb2 = cb || rethrow; const entity = findVirtualFileSystemEntry(path_); if (!entity) return cb2(error_ENOENT('File or directory', path_)); const dock = { path: path_, entity, position: 0 }; const nullDevice = windows ? '\\\\.\\NUL' : '/dev/null'; if (cb) { ancestor.open.call(fs, nullDevice, 'r', (error, fd) => { if (error) return cb(error); if (DOCOMPRESS) { dock._externalFile = uncompressExternallyAndOpen(dock); } docks[fd] = dock; cb(null, fd); }); } else { const fd = ancestor.openSync.call(fs, nullDevice, 'r'); if (DOCOMPRESS) { dock._externalFile = uncompressExternallyAndOpen(dock); } docks[fd] = dock; return fd; } } fs.createReadStream = function createReadStream(path_) { if (!insideSnapshot(path_)) { return ancestor.createReadStream.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.createReadStream.apply( fs, translateNth(arguments, 0, path_) ); } const stream = ancestor.createReadStream.apply(fs, arguments); return stream; }; fs.openSync = function openSync(path_) { if (!insideSnapshot(path_)) { return ancestor.openSync.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.openSync.apply(fs, translateNth(arguments, 0, path_)); } return openFromSnapshot(path_, DOCOMPRESS); }; fs.open = function open(path_) { if (!insideSnapshot(path_)) { return ancestor.open.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.open.apply(fs, translateNth(arguments, 0, path_)); } const callback = dezalgo(maybeCallback(arguments)); openFromSnapshot(path_, DOCOMPRESS, callback); }; // /////////////////////////////////////////////////////////////// // read ////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// function readFromSnapshotSub( entityContent, dock, buffer, offset, length, position, cb ) { if (DOCOMPRESS) { // note: source contains info about a compressed file and source[1] does not reflect // the actual size of the file. // so random access reading of a compressed virtual file, requires read from // an externally decompressed file if (!dock._externalFile) { dock._externalFile = uncompressExternallyAndOpen(dock); } else { position = position === undefined ? 0 : position; } return fs.read(dock._externalFile, buffer, offset, length, position, cb); } let p; if (position !== null && position !== undefined) { p = position; } else { p = dock.position; } if (cb) { payloadCopyUni( entityContent, buffer, offset, p, p + length, (error, bytesRead, buffer2) => { if (error) return cb(error); dock.position = p + bytesRead; cb(null, bytesRead, buffer2); } ); } else { const bytesRead = payloadCopyUni( entityContent, buffer, offset, p, p + length ); dock.position = p + bytesRead; return bytesRead; } } function readFromSnapshot(fd, buffer, offset, length, position, cb) { const dock = docks[fd]; if (dock && dock._externalFile) { if (cb) { return ancestor.read( dock._externalFile, buffer, offset, length, position, cb ); } return ancestor.readSync( dock._externalFile, buffer, offset, length, position ); } const cb2 = cb || rethrow; if (offset < 0 && NODE_VERSION_MAJOR >= 14) return cb2( new Error( `The value of "offset" is out of range. It must be >= 0. Received ${offset}` ) ); if (offset < 0 && NODE_VERSION_MAJOR >= 10) return cb2( new Error( `The value of "offset" is out of range. It must be >= 0 && <= ${buffer.length.toString()}. Received ${offset}` ) ); if (offset < 0) return cb2(new Error('Offset is out of bounds')); if (offset >= buffer.length) return cb2(null, 0); if (offset + length > buffer.length && NODE_VERSION_MAJOR >= 14) return cb2( new Error( `The value of "length" is out of range. It must be <= ${( buffer.length - offset ).toString()}. Received ${length.toString()}` ) ); if (offset + length > buffer.length && NODE_VERSION_MAJOR >= 10) return cb2( new Error( `The value of "length" is out of range. It must be >= 0 && <= ${( buffer.length - offset ).toString()}. Received ${length.toString()}` ) ); if (offset + length > buffer.length) return cb2(new Error('Length extends beyond buffer')); const { entity } = dock; const entityLinks = entity[STORE_LINKS]; if (entityLinks) return cb2(error_EISDIR(dock.path)); const entityContent = entity[STORE_CONTENT]; if (entityContent) return readFromSnapshotSub( entityContent, dock, buffer, offset, length, position, cb ); return cb2(new Error('UNEXPECTED-15')); } fs.readSync = function readSync(fd, buffer, offset, length, position) { if (!docks[fd]) { return ancestor.readSync.apply(fs, arguments); } return readFromSnapshot(fd, buffer, offset, length, position); }; fs.read = function read(fd, buffer, offset, length, position) { if (!docks[fd]) { return ancestor.read.apply(fs, arguments); } const callback = dezalgo(maybeCallback(arguments)); readFromSnapshot(fd, buffer, offset, length, position, callback); }; // /////////////////////////////////////////////////////////////// // write ///////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// function writeToSnapshot(cb) { const cb2 = cb || rethrow; return cb2(new Error('Cannot write to packaged file')); } fs.writeSync = function writeSync(fd) { if (!docks[fd]) { return ancestor.writeSync.apply(fs, arguments); } return writeToSnapshot(); }; fs.write = function write(fd) { if (!docks[fd]) { return ancestor.write.apply(fs, arguments); } const callback = dezalgo(maybeCallback(arguments)); return writeToSnapshot(callback); }; // /////////////////////////////////////////////////////////////// // close ///////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// const closeFromSnapshot = (fd, cb) => { const dock = docks[fd]; if (dock._externalFile) { ancestor.closeSync(dock._externalFile); dock._externalFile = undefined; } delete docks[fd]; if (cb) { ancestor.close.call(fs, fd, cb); } else { return ancestor.closeSync.call(fs, fd); } }; fs.closeSync = function closeSync(fd) { if (!docks[fd]) { return ancestor.closeSync.apply(fs, arguments); } return closeFromSnapshot(fd); }; fs.close = function close(fd) { if (!docks[fd]) { return ancestor.close.apply(fs, arguments); } const callback = dezalgo(maybeCallback(arguments)); closeFromSnapshot(fd, callback); }; // /////////////////////////////////////////////////////////////// // readFile ////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// function readFileOptions(options, hasCallback) { if (!options || (hasCallback && typeof options === 'function')) { return { encoding: null, flag: 'r' }; } if (typeof options === 'string') { return { encoding: options, flag: 'r' }; } if (typeof options === 'object') { return options; } return null; } function readFileFromSnapshotSub(entityContent, cb) { if (cb) { payloadFile(entityContent, cb); } else { return payloadFileSync(entityContent); } } function readFileFromSnapshot(path_, cb) { const cb2 = cb || rethrow; const entity = findVirtualFileSystemEntry(path_); if (!entity) return cb2(error_ENOENT('File', path_)); const entityLinks = entity[STORE_LINKS]; if (entityLinks) return cb2(error_EISDIR(path_)); const entityContent = entity[STORE_CONTENT]; if (entityContent) return readFileFromSnapshotSub(entityContent, cb); const entityBlob = entity[STORE_BLOB]; if (entityBlob) { return cb2(null, Buffer.from('source-code-not-available')); } // why return empty buffer? // otherwise this error will arise: // Error: UNEXPECTED-20 // at readFileFromSnapshot (e:0) // at Object.fs.readFileSync (e:0) // at Object.Module._extensions..js (module.js:421:20) // at Module.load (module.js:357:32) // at Function.Module._load (module.js:314:12) // at Function.Module.runMain (e:0) // at startup (node.js:140:18) // at node.js:1001:3 return cb2(new Error('UNEXPECTED-20')); } fs.readFileSync = function readFileSync(path_, options_) { if (path_ === 'dirty-hack-for-testing-purposes') { return path_; } if (!insideSnapshot(path_)) { return ancestor.readFileSync.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.readFileSync.apply(fs, translateNth(arguments, 0, path_)); } const options = readFileOptions(options_, false); if (!options) { return ancestor.readFileSync.apply(fs, arguments); } const { encoding } = options; assertEncoding(encoding); let buffer = readFileFromSnapshot(path_); if (encoding) buffer = buffer.toString(encoding); return buffer; }; fs.readFile = function readFile(path_, options_) { if (!insideSnapshot(path_)) { return ancestor.readFile.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.readFile.apply(fs, translateNth(arguments, 0, path_)); } const options = readFileOptions(options_, true); if (!options) { return ancestor.readFile.apply(fs, arguments); } const { encoding } = options; assertEncoding(encoding); const callback = dezalgo(maybeCallback(arguments)); readFileFromSnapshot(path_, (error, buffer) => { if (error) return callback(error); if (encoding) buffer = buffer.toString(encoding); callback(null, buffer); }); }; fs.copyFile = function copyFile(src, dest, flags, callback) { if (!insideSnapshot(path.resolve(src))) { ancestor.copyFile(src, dest, flags, callback); return; } if (typeof flags === 'function') { callback = flags; flags = 0; } else if (typeof callback !== 'function') { throw new TypeError('Callback must be a function'); } function _streamCopy() { fs.createReadStream(src) .on('error', callback) .pipe(fs.createWriteStream(dest)) .on('error', callback) .on('finish', callback); } if (flags & fs.constants.COPYFILE_EXCL) { fs.stat(dest, (statError) => { if (!statError) { callback( Object.assign(new Error('File already exists'), { code: 'EEXIST', }) ); return; } if (statError.code !== 'ENOENT') { callback(statError); return; } _streamCopy(); }); } else { _streamCopy(); } }; fs.copyFileSync = function copyFileSync(src, dest, flags) { if (!insideSnapshot(path.resolve(src))) { ancestor.copyFileSync(src, dest, flags); return; } if (flags & fs.constants.COPYFILE_EXCL) { try { fs.statSync(dest); } catch (statError) { if (statError.code !== 'ENOENT') throw statError; copyInChunks(src, dest, DEFAULT_COPY_CHUNK_SIZE, fs); return; } throw Object.assign(new Error('File already exists'), { code: 'EEXIST' }); } copyInChunks(src, dest, DEFAULT_COPY_CHUNK_SIZE, fs); }; // /////////////////////////////////////////////////////////////// // writeFile ///////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// // writeFileSync based on openSync/writeSync/closeSync // writeFile based on open/write/close // /////////////////////////////////////////////////////////////// // readdir /////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// function readdirOptions(options, hasCallback) { if (!options || (hasCallback && typeof options === 'function')) { return { encoding: null }; } if (typeof options === 'string') { return { encoding: options }; } if (typeof options === 'object') { return options; } return null; } function Dirent(name, type) { this.name = name; this.type = type; } Dirent.prototype.isDirectory = function isDirectory() { return this.type === 2; }; Dirent.prototype.isFile = function isFile() { return this.type === 1; }; const noop = () => false; Dirent.prototype.isBlockDevice = noop; Dirent.prototype.isCharacterDevice = noop; Dirent.prototype.isSocket = noop; Dirent.prototype.isFIFO = noop; Dirent.prototype.isSymbolicLink = (fileOrFolderName) => Boolean(SYMLINKS[fileOrFolderName]); function getFileTypes(path_, entries) { return entries.map((entry) => { const ff = path.join(path_, entry); const entity = findVirtualFileSystemEntry(ff); if (!entity) return undefined; if (entity[STORE_BLOB] || entity[STORE_CONTENT]) return new Dirent(entry, 1); if (entity[STORE_LINKS]) return new Dirent(entry, 2); throw new Error('UNEXPECTED-24'); }); } function readdirRoot(path_, options, cb) { function addSnapshot(entries) { if (options && options.withFileTypes) { entries.push(new Dirent('snapshot', 2)); } else { entries.push('snapshot'); } } if (cb) { ancestor.readdir(path_, options, (error, entries) => { if (error) return cb(error); addSnapshot(entries); cb(null, entries); }); } else { const entries = ancestor.readdirSync(path_, options); addSnapshot(entries); return entries; } } function readdirFromSnapshotSub(entityLinks, path_, cb) { if (cb) { payloadFile(entityLinks, (error, buffer) => { if (error) return cb(error); cb(null, JSON.parse(buffer).concat(readdirMountpoints(path_))); }); } else { const buffer = payloadFileSync(entityLinks); return JSON.parse(buffer).concat(readdirMountpoints(path_)); } } function readdirFromSnapshot(path_, cb) { const cb2 = cb || rethrow; const entity = findVirtualFileSystemEntry(path_); if (!entity) { return cb2(error_ENOENT('Directory', path_)); } const entityBlob = entity[STORE_BLOB]; if (entityBlob) { return cb2(error_ENOTDIR(path_)); } const entityContent = entity[STORE_CONTENT]; if (entityContent) { return cb2(error_ENOTDIR(path_)); } const entityLinks = entity[STORE_LINKS]; if (entityLinks) { return readdirFromSnapshotSub(entityLinks, path_, cb); } return cb2(new Error('UNEXPECTED-25')); } fs.readdirSync = function readdirSync(path_, options_) { const isRoot = isRootPath(path_); if (!insideSnapshot(path_) && !isRoot) { return ancestor.readdirSync.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.readdirSync.apply(fs, translateNth(arguments, 0, path_)); } const options = readdirOptions(options_, false); if (isRoot) { return readdirRoot(path_, options); } if (!options) { return ancestor.readdirSync.apply(fs, arguments); } let entries = readdirFromSnapshot(path_); if (options.withFileTypes) entries = getFileTypes(path_, entries); return entries; }; fs.readdir = function readdir(path_, options_) { const isRoot = isRootPath(path_); if (!insideSnapshot(path_) && !isRoot) { return ancestor.readdir.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.readdir.apply(fs, translateNth(arguments, 0, path_)); } const options = readdirOptions(options_, true); const callback = dezalgo(maybeCallback(arguments)); if (isRoot) { return readdirRoot(path_, options, callback); } if (!options) { return ancestor.readdir.apply(fs, arguments); } readdirFromSnapshot(path_, (error, entries) => { if (error) return callback(error); if (options.withFileTypes) entries = getFileTypes(path_, entries); callback(null, entries); }); }; // /////////////////////////////////////////////////////////////// // realpath ////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// fs.realpathSync = function realpathSync(path_) { if (!insideSnapshot(path_)) { return ancestor.realpathSync.apply(fs, arguments); } if (insideMountpoint(path_)) { // app should not know real file name return path_; } const realPath = realpathFromSnapshot(path_); return realPath; }; fs.realpath = function realpath(path_) { if (!insideSnapshot(path_)) { return ancestor.realpath.apply(fs, arguments); } if (insideMountpoint(path_)) { // app should not know real file name return path_; } const callback = dezalgo(maybeCallback(arguments)); callback(null, realpathFromSnapshot(path_)); }; fs.realpathSync.native = fs.realpathSync; fs.realpath.native = fs.realpath; // /////////////////////////////////////////////////////////////// // stat ////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// function restore(s) { s.blksize = 4096; s.blocks = 0; s.dev = 0; s.gid = 20; s.ino = 0; s.nlink = 0; s.rdev = 0; s.uid = 500; s.atime = new Date(EXECSTAT.atime); s.mtime = new Date(EXECSTAT.mtime); s.ctime = new Date(EXECSTAT.ctime); s.birthtime = new Date(EXECSTAT.birthtime); s.atimeMs = EXECSTAT.atimeMs; s.mtimeMs = EXECSTAT.mtimeMs; s.ctimeMs = EXECSTAT.ctimeMs; s.birthtimeMs = EXECSTAT.birthtimeMs; const { isFileValue } = s; const { isDirectoryValue } = s; const { isSocketValue } = s; const { isSymbolicLinkValue } = s; delete s.isFileValue; delete s.isDirectoryValue; delete s.isSocketValue; delete s.isSymbolicLinkValue; s.isBlockDevice = noop; s.isCharacterDevice = noop; s.isFile = function isFile() { return isFileValue; }; s.isDirectory = function isDirectory() { return isDirectoryValue; }; s.isSocket = function isSocket() { return isSocketValue; }; s.isSymbolicLink = function isSymbolicLink() { return isSymbolicLinkValue; }; s.isFIFO = noop; return s; } function findNativeAddonForStat(path_, cb) { const cb2 = cb || rethrow; const foundPath = findNativeAddonSyncUnderRequire(path_); if (!foundPath) return cb2(error_ENOENT('File or directory', path_)); if (cb) { ancestor.stat.call(fs, foundPath, cb); } else { return ancestor.statSync.call(fs, foundPath); } } function statFromSnapshotSub(entityStat, cb) { if (cb) { payloadFile(entityStat, (error, buffer) => { if (error) return cb(error); cb(null, restore(JSON.parse(buffer))); }); } else { const buffer = payloadFileSync(entityStat); return restore(JSON.parse(buffer)); } } function statFromSnapshot(path_, cb) { const cb2 = cb || rethrow; const entity = findVirtualFileSystemEntry(path_); if (!entity) return findNativeAddonForStat(path_, cb); const entityStat = entity[STORE_STAT]; if (entityStat) return statFromSnapshotSub(entityStat, cb); return cb2(new Error('UNEXPECTED-35')); } fs.statSync = function statSync(path_) { if (!insideSnapshot(path_)) { return ancestor.statSync.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.statSync.apply(fs, translateNth(arguments, 0, path_)); } return statFromSnapshot(path_); }; fs.stat = function stat(path_) { if (!insideSnapshot(path_)) { return ancestor.stat.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.stat.apply(fs, translateNth(arguments, 0, path_)); } const callback = dezalgo(maybeCallback(arguments)); statFromSnapshot(path_, callback); }; // /////////////////////////////////////////////////////////////// // lstat ///////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// fs.lstatSync = function lstatSync(path_) { if (!insideSnapshot(path_)) { return ancestor.lstatSync.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.lstatSync.apply(fs, translateNth(arguments, 0, path_)); } return statFromSnapshot(path_); }; fs.lstat = function lstat(path_) { if (!insideSnapshot(path_)) { return ancestor.lstat.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.lstat.apply(fs, translateNth(arguments, 0, path_)); } const callback = dezalgo(maybeCallback(arguments)); statFromSnapshot(path_, callback); }; // /////////////////////////////////////////////////////////////// // fstat ///////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// function fstatFromSnapshot(fd, cb) { const cb2 = cb || rethrow; const { entity } = docks[fd]; const entityStat = entity[STORE_STAT]; if (entityStat) return statFromSnapshotSub(entityStat, cb); return cb2(new Error('UNEXPECTED-40')); } fs.fstatSync = function fstatSync(fd) { if (!docks[fd]) { return ancestor.fstatSync.apply(fs, arguments); } return fstatFromSnapshot(fd); }; fs.fstat = function fstat(fd) { if (!docks[fd]) { return ancestor.fstat.apply(fs, arguments); } const callback = dezalgo(maybeCallback(arguments)); fstatFromSnapshot(fd, callback); }; // /////////////////////////////////////////////////////////////// // exists //////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// function findNativeAddonForExists(path_) { const foundPath = findNativeAddonSyncFreeFromRequire(path_); if (!foundPath) return false; return ancestor.existsSync.call(fs, foundPath); } function existsFromSnapshot(path_) { const entity = findVirtualFileSystemEntry(path_); if (!entity) return findNativeAddonForExists(path_); return true; } fs.existsSync = function existsSync(path_) { if (!insideSnapshot(path_)) { return ancestor.existsSync.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.existsSync.apply(fs, translateNth(arguments, 0, path_)); } return existsFromSnapshot(path_); }; fs.exists = function exists(path_) { if (!insideSnapshot(path_)) { return ancestor.exists.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.exists.apply(fs, translateNth(arguments, 0, path_)); } const callback = dezalgo(maybeCallback(arguments)); callback(existsFromSnapshot(path_)); }; // /////////////////////////////////////////////////////////////// // access //////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// function accessFromSnapshot(path_, cb) { const cb2 = cb || rethrow; const entity = findVirtualFileSystemEntry(path_); if (!entity) return cb2(error_ENOENT('File or directory', path_)); return cb2(null, undefined); } fs.accessSync = function accessSync(path_) { if (!insideSnapshot(path_)) { return ancestor.accessSync.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.accessSync.apply(fs, translateNth(arguments, 0, path_)); } return accessFromSnapshot(path_); }; fs.access = function access(path_) { if (!insideSnapshot(path_)) { return ancestor.access.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.access.apply(fs, translateNth(arguments, 0, path_)); } const callback = dezalgo(maybeCallback(arguments)); accessFromSnapshot(path_, callback); }; // /////////////////////////////////////////////////////////////// // mkdir ///////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// function mkdirFailInSnapshot(path_, cb) { const cb2 = cb || rethrow; return cb2( new Error('Cannot mkdir in a snapshot. Try mountpoints instead.') ); } fs.mkdirSync = function mkdirSync(path_) { if (!insideSnapshot(path_)) { return ancestor.mkdirSync.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.mkdirSync.apply(fs, translateNth(arguments, 0, path_)); } return mkdirFailInSnapshot(path_); }; fs.mkdir = function mkdir(path_) { if (!insideSnapshot(path_)) { return ancestor.mkdir.apply(fs, arguments); } if (insideMountpoint(path_)) { return ancestor.mkdir.apply(fs, translateNth(arguments, 0, path_)); } mkdirFailInSnapshot(path_, dezalgo(maybeCallback(arguments))); }; // /////////////////////////////////////////////////////////////// // promises //////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// if (fs.promises !== undefined) { const ancestor_promises = { open: fs.promises.open, read: fs.promises.read, write: fs.promises.write, readFile: fs.promises.readFile, readdir: fs.promises.readdir, realpath: fs.promises.realpath, stat: fs.promises.stat, lstat: fs.promises.lstat, fstat: fs.promises.fstat, access: fs.promises.access, copyFile: fs.promises.copyFile, }; fs.promises.open = async function open(path_) { if (!insideSnapshot(path_)) { return ancestor_promises.open.apply(this, arguments); } if (insideMountpoint(path_)) { return ancestor_promises.open.apply( this, translateNth(arguments, 0, path_) ); } const externalFile = uncompressExternallyPath(path_); arguments[0] = externalFile; const fd = await ancestor_promises.open.apply(this, arguments); if (typeof fd === 'object') { fd._pkg = { externalFile, file: path_ }; } return fd; }; fs.promises.readFile = async function readFile(path_) { if (!insideSnapshot(path_)) { return ancestor_promises.readFile.apply(this, arguments); } if (insideMountpoint(path_)) { return ancestor_promises.readFile.apply( this, translateNth(arguments, 0, path_) ); } const externalFile = uncompressExternallyPath(path_); arguments[0] = externalFile; return ancestor_promises.readFile.apply(this, arguments); }; fs.promises.write = async function write(fd) { if (fd._pkg) { throw new Error( `[PKG] Cannot write into Snapshot file : ${fd._pkg.file}` ); } return ancestor_promises.write.apply(this, arguments); }; // this one use promisify on purpose fs.promises.readdir = util.promisify(fs.readdir); fs.promises.copyFile = util.promisify(fs.copyFile); fs.promises.stat = util.promisify(fs.stat); fs.promises.lstat = util.promisify(fs.lstat); /* fs.promises.read = util.promisify(fs.read); fs.promises.realpath = util.promisify(fs.realpath); fs.promises.fstat = util.promisify(fs.fstat); fs.promises.access = util.promisify(fs.access); */ } // /////////////////////////////////////////////////////////////// // INTERNAL ////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// function makeLong(f) { return path._makeLong(f); } function revertMakingLong(f) { if (/^\\\\\?\\/.test(f)) return f.slice(4); return f; } function findNativeAddonForInternalModuleStat(path_) { const fNative = findNativeAddonSyncUnderRequire(path_); if (!fNative) return -ENOENT; return process.binding('fs').internalModuleStat(makeLong(fNative)); } fs.internalModuleStat = function internalModuleStat(long) { // from node comments: // Used to speed up module loading. Returns 0 if the path refers to // a file, 1 when it's a directory or < 0 on error (usually -ENOENT). // The speedup comes from not creating thousands of Stat and Error objects. const path_ = revertMakingLong(long); if (!insideSnapshot(path_)) { return process.binding('fs').internalModuleStat(long); } if (insideMountpoint(path_)) { return process .binding('fs') .internalModuleStat(makeLong(translate(path_))); } const entity = findVirtualFileSystemEntry(path_); if (!entity) { return findNativeAddonForInternalModuleStat(path_); } const entityBlob = entity[STORE_BLOB]; if (entityBlob) { return 0; } const entityContent = entity[STORE_CONTENT]; if (entityContent) { return 0; } const entityLinks = entity[STORE_LINKS]; if (entityLinks) { return 1; } return -ENOENT; }; fs.internalModuleReadJSON = function internalModuleReadJSON(long) { // from node comments: // Used to speed up module loading. Returns the contents of the file as // a string or undefined when the file cannot be opened. The speedup // comes from not creating Error objects on failure. // For newer node versions (after https://github.com/nodejs/node/pull/33229 ): // Returns an array [string, boolean]. // const returnArray = (NODE_VERSION_MAJOR === 12 && NODE_VERSION_MINOR >= 19) || (NODE_VERSION_MAJOR === 14 && NODE_VERSION_MINOR >= 5) || NODE_VERSION_MAJOR >= 15; const path_ = revertMakingLong(long); const bindingFs = process.binding('fs'); const readFile = ( bindingFs.internalModuleReadFile || bindingFs.internalModuleReadJSON ).bind(bindingFs); if (!insideSnapshot(path_)) { return readFile(long); } if (insideMountpoint(path_)) { return readFile(makeLong(translate(path_))); } const entity = findVirtualFileSystemEntry(path_); if (!entity) { return returnArray ? [undefined, false] : undefined; } const entityContent = entity[STORE_CONTENT]; if (!entityContent) { return returnArray ? [undefined, false] : undefined; } return returnArray ? [payloadFileSync(entityContent).toString(), true] : payloadFileSync(entityContent).toString(); }; fs.internalModuleReadFile = fs.internalModuleReadJSON; })(); // ///////////////////////////////////////////////////////////////// // PATCH MODULE //////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////// (() => { const ancestor = { require: Module.prototype.require, _compile: Module.prototype._compile, _resolveFilename: Module._resolveFilename, runMain: Module.runMain, }; Module.prototype.require = function require(path_) { try { return ancestor.require.apply(this, arguments); } catch (error) { if ( (error.code === 'ENOENT' || error.code === 'MODULE_NOT_FOUND') && !insideSnapshot(path_) && !path.isAbsolute(path_) ) { if (!error.pkg) { error.pkg = true; error.message += '\n' + '1) If you want to compile the package/file into ' + 'executable, please pay attention to compilation ' + "warnings and specify a literal in 'require' call. " + "2) If you don't want to compile the package/file " + "into executable and want to 'require' it from " + 'filesystem (likely plugin), specify an absolute ' + "path in 'require' call using process.cwd() or " + 'process.execPath.'; } } throw error; } }; let im; let makeRequireFunction; if (NODE_VERSION_MAJOR <= 9) { im = require('internal/module'); makeRequireFunction = im.makeRequireFunction; } else { if (NODE_VERSION_MAJOR <= 18) { im = require('internal/modules/cjs/helpers'); } else { im = require('internal/modules/helpers'); } makeRequireFunction = im.makeRequireFunction; // TODO esm modules along with cjs } Module.prototype._compile = function _compile(content, filename_) { if (!insideSnapshot(filename_)) { return ancestor._compile.apply(this, arguments); } if (insideMountpoint(filename_)) { // DON'T TRANSLATE! otherwise __dirname gets real name return ancestor._compile.apply(this, arguments); } const entity = findVirtualFileSystemEntry(filename_); if (!entity) { // let user try to "_compile" a packaged file return ancestor._compile.apply(this, arguments); } const entityBlob = entity[STORE_BLOB]; const entityContent = entity[STORE_CONTENT]; if (entityBlob) { const options = { filename: filename_, lineOffset: 0, displayErrors: true, cachedData: payloadFileSync(entityBlob), sourceless: !entityContent, }; const code = entityContent ? Module.wrap(payloadFileSync(entityContent)) : undefined; const script = new Script(code, options); const wrapper = script.runInThisContext(options); if (!wrapper) process.exit(4); // for example VERSION_MISMATCH const dirname = path.dirname(filename_); const rqfn = makeRequireFunction(this); const args = [this.exports, rqfn, this, filename_, dirname]; return wrapper.apply(this.exports, args); } if (entityContent) { if (entityBlob) throw new Error('UNEXPECTED-50'); // content is already in utf8 and without BOM (that is expected // by stock _compile), but entityContent is still a Buffer return ancestor._compile.apply(this, arguments); } throw new Error('UNEXPECTED-55'); }; Module._resolveFilename = function _resolveFilename() { let filename; let flagWasOn = false; try { filename = ancestor._resolveFilename.apply(this, arguments); } catch (error) { if (error.code !== 'MODULE_NOT_FOUND') throw error; FLAG_ENABLE_PROJECT = true; const savePathCache = Module._pathCache; Module._pathCache = Object.create(null); try { filename = ancestor._resolveFilename.apply(this, arguments); flagWasOn = true; } finally { Module._pathCache = savePathCache; FLAG_ENABLE_PROJECT = false; } } if (!insideSnapshot(filename)) { return filename; } if (insideMountpoint(filename)) { return filename; } if (flagWasOn) { FLAG_ENABLE_PROJECT = true; try { const found = findNativeAddonSyncUnderRequire(filename); if (found) filename = found; } finally { FLAG_ENABLE_PROJECT = false; } } return filename; }; Module.runMain = function runMain() { Module._load(ENTRYPOINT, null, true); process._tickCallback(); }; })(); // ///////////////////////////////////////////////////////////////// // PATCH CHILD_PROCESS ///////////////////////////////////////////// // ///////////////////////////////////////////////////////////////// (() => { const ancestor = { spawn: childProcess.spawn, spawnSync: childProcess.spawnSync, execFile: childProcess.execFile, execFileSync: childProcess.execFileSync, exec: childProcess.exec, execSync: childProcess.execSync, }; function setOptsEnv(args) { let pos = args.length - 1; if (typeof args[pos] === 'function') pos -= 1; if (typeof args[pos] !== 'object' || Array.isArray(args[pos])) { pos += 1; args.splice(pos, 0, {}); } const opts = args[pos]; if (!opts.env) opts.env = _extend({}, process.env); if (opts.env.PKG_EXECPATH === 'PKG_INVOKE_NODEJS') return; opts.env.PKG_EXECPATH = EXECPATH; } function startsWith2(args, index, name, impostor) { const qsName = `"${name} `; if (args[index].slice(0, qsName.length) === qsName) { args[index] = `"${impostor} ${args[index].slice(qsName.length)}`; return true; } const sName = `${name} `; if (args[index].slice(0, sName.length) === sName) { args[index] = `${impostor} ${args[index].slice(sName.length)}`; return true; } if (args[index] === name) { args[index] = impostor; return true; } return false; } function startsWith(args, index, name) { const qName = `"${name}"`; const qEXECPATH = `"${EXECPATH}"`; const jsName = JSON.stringify(name); const jsEXECPATH = JSON.stringify(EXECPATH); return ( startsWith2(args, index, name, EXECPATH) || startsWith2(args, index, qName, qEXECPATH) || startsWith2(args, index, jsName, jsEXECPATH) ); } function modifyLong(args, index) { if (!args[index]) return; return ( startsWith(args, index, 'node') || startsWith(args, index, ARGV0) || startsWith(args, index, ENTRYPOINT) || startsWith(args, index, EXECPATH) ); } function modifyShort(args) { if (!args[0]) return; if (!Array.isArray(args[1])) { args.splice(1, 0, []); } if ( args[0] === 'node' || args[0] === ARGV0 || args[0] === ENTRYPOINT || args[0] === EXECPATH ) { args[0] = EXECPATH; } else { for (let i = 1; i < args[1].length; i += 1) { const mbc = args[1][i - 1]; if (mbc === '-c' || mbc === '/c') { modifyLong(args[1], i); } } } } childProcess.spawn = function spawn() { const args = cloneArgs(arguments); setOptsEnv(args); modifyShort(args); return ancestor.spawn.apply(childProcess, args); }; childProcess.spawnSync = function spawnSync() { const args = cloneArgs(arguments); setOptsEnv(args); modifyShort(args); return ancestor.spawnSync.apply(childProcess, args); }; childProcess.execFile = function execFile() { const args = cloneArgs(arguments); setOptsEnv(args); modifyShort(args); return ancestor.execFile.apply(childProcess, args); }; childProcess.execFileSync = function execFileSync() { const args = cloneArgs(arguments); setOptsEnv(args); modifyShort(args); return ancestor.execFileSync.apply(childProcess, args); }; childProcess.exec = function exec() { const args = cloneArgs(arguments); setOptsEnv(args); modifyLong(args, 0); return ancestor.exec.apply(childProcess, args); }; childProcess.execSync = function execSync() { const args = cloneArgs(arguments); setOptsEnv(args); modifyLong(args, 0); return ancestor.execSync.apply(childProcess, args); }; })(); // ///////////////////////////////////////////////////////////////// // PROMISIFY /////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////// (() => { const { custom } = promisify; const { customPromisifyArgs } = require('internal/util'); // ///////////////////////////////////////////////////////////// // FS ////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////// Object.defineProperty(fs.exists, custom, { value(path_) { return new Promise((resolve) => { fs.exists(path_, (exists) => { resolve(exists); }); }); }, }); Object.defineProperty(fs.read, customPromisifyArgs, { value: ['bytesRead', 'buffer'], }); Object.defineProperty(fs.write, customPromisifyArgs, { value: ['bytesWritten', 'buffer'], }); // ///////////////////////////////////////////////////////////// // CHILD_PROCESS /////////////////////////////////////////////// // ///////////////////////////////////////////////////////////// const customPromiseExecFunction = (o) => (...args) => { let resolve; let reject; const p = new Promise((res, rej) => { resolve = res; reject = rej; }); p.child = o.apply( undefined, args.concat((error, stdout, stderr) => { if (error !== null) { error.stdout = stdout; error.stderr = stderr; reject(error); } else { resolve({ stdout, stderr }); } }) ); return p; }; Object.defineProperty(childProcess.exec, custom, { value: customPromiseExecFunction(childProcess.exec), }); Object.defineProperty(childProcess.execFile, custom, { value: customPromiseExecFunction(childProcess.execFile), }); })(); // ///////////////////////////////////////////////////////////////// // PATCH PROCESS /////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////// (() => { const ancestor = { dlopen: process.dlopen, }; function revertMakingLong(f) { if (/^\\\\\?\\/.test(f)) return f.slice(4); return f; } process.dlopen = function dlopen() { const args = cloneArgs(arguments); const modulePath = revertMakingLong(args[1]); const moduleBaseName = path.basename(modulePath); const moduleFolder = path.dirname(modulePath); if (insideSnapshot(modulePath)) { const moduleContent = fs.readFileSync(modulePath); // Node addon files and .so cannot be read with fs directly, they are loaded with process.dlopen which needs a filesystem path // we need to write the file somewhere on disk first and then load it // the hash is needed to be sure we reload the module in case it changes const hash = createHash('sha256').update(moduleContent).digest('hex'); // Example: /tmp/pkg/ const tmpFolder = path.join(tmpdir(), 'pkg', hash); createDirRecursively(tmpFolder); // Example: moduleFolder = /snapshot/appname/node_modules/sharp/build/Release const parts = moduleFolder.split(path.sep); const mIndex = parts.indexOf('node_modules') + 1; let newPath; // it's a node addon file contained in node_modules folder // we copy the entire module folder in tmp folder if (mIndex > 0) { // Example: modulePackagePath = sharp/build/Release const modulePackagePath = parts.slice(mIndex).join(path.sep); // Example: modulePkgFolder = /snapshot/appname/node_modules/sharp const modulePkgFolder = parts.slice(0, mIndex + 1).join(path.sep); // here we copy all files from the snapshot module folder to temporary folder // we keep the module folder structure to prevent issues with modules that are statically // linked using relative paths (Fix #1075) copyFolderRecursiveSync(modulePkgFolder, tmpFolder); // Example: /tmp/pkg//sharp/build/Release/sharp.node newPath = path.join(tmpFolder, modulePackagePath, moduleBaseName); } else { const tmpModulePath = path.join(tmpFolder, moduleBaseName); if (!fs.existsSync(tmpModulePath)) { fs.copyFileSync(modulePath, tmpModulePath); } // load the copied file in the temporary folder newPath = tmpModulePath; } // replace the path with the new module path args[1] = newPath; } return ancestor.dlopen.apply(process, args); }; })(); ================================================ FILE: prelude/diagnostic.js ================================================ /* eslint-disable global-require */ /* eslint-disable no-console */ /* global DICT */ 'use strict'; (function installDiagnostic() { const fs = require('fs'); const path = require('path'); const win32 = process.platform === 'win32'; if (process.env.DEBUG_PKG === '2') { console.log(Object.entries(DICT)); } function dumpLevel(filename, level, tree) { let totalSize = 0; const d = fs.readdirSync(filename); for (let j = 0; j < d.length; j += 1) { const f = path.join(filename, d[j]); const realPath = fs.realpathSync(f); const isSymbolicLink2 = f !== realPath; const s = fs.statSync(f); totalSize += s.size; if (s.isDirectory() && !isSymbolicLink2) { const tree1 = []; totalSize += dumpLevel(f, level + 1, tree1); const str = (' '.padStart(level * 2, ' ') + d[j]).padEnd(40, ' ') + (totalSize.toString().padStart(10, ' ') + (isSymbolicLink2 ? `=> ${realPath}` : ' ')); tree.push(str); tree1.forEach((x) => tree.push(x)); } else { const str = (' '.padStart(level * 2, ' ') + d[j]).padEnd(40, ' ') + (s.size.toString().padStart(10, ' ') + (isSymbolicLink2 ? `=> ${realPath}` : ' ')); tree.push(str); } } return totalSize; } function wrap(obj, name) { const f = fs[name]; obj[name] = (...args) => { const args1 = Object.values(args); console.log( `fs.${name}`, args1.filter((x) => typeof x === 'string') ); return f.apply(this, args1); }; } if (process.env.DEBUG_PKG) { console.log('------------------------------- virtual file system'); const startFolder = win32 ? 'C:\\snapshot' : '/snapshot'; console.log(startFolder); const tree = []; const totalSize = dumpLevel(startFolder, 1, tree); console.log(tree.join('\n')); console.log('Total size = ', totalSize); if (process.env.DEBUG_PKG === '2') { wrap(fs, 'openSync'); wrap(fs, 'open'); wrap(fs, 'readSync'); wrap(fs, 'read'); wrap(fs, 'writeSync'); wrap(fs, 'write'); wrap(fs, 'closeSync'); wrap(fs, 'readFileSync'); wrap(fs, 'close'); wrap(fs, 'readFile'); wrap(fs, 'readdirSync'); wrap(fs, 'readdir'); wrap(fs, 'realpathSync'); wrap(fs, 'realpath'); wrap(fs, 'statSync'); wrap(fs, 'stat'); wrap(fs, 'lstatSync'); wrap(fs, 'lstat'); wrap(fs, 'fstatSync'); wrap(fs, 'fstat'); wrap(fs, 'existsSync'); wrap(fs, 'exists'); wrap(fs, 'accessSync'); wrap(fs, 'access'); } } })(); ================================================ FILE: test/.eslintrc.json ================================================ { "parserOptions": { "sourceType": "script" }, "rules": { "no-var": "off", "prefer-const": "off", "vars-on-top": "off" } } ================================================ FILE: test/.gitignore ================================================ node_modules/ ================================================ FILE: test/test-42-fetch-all/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const fetch = require('pkg-fetch'); const dontBuild = require('pkg-fetch/lib-es5/upload.js').dontBuild; const knownPlatforms = fetch.system.knownPlatforms; const items = []; function nodeRangeToNodeVersion(nodeRange) { assert(/^node/.test(nodeRange)); return 'v' + nodeRange.slice(4); } for (const platform of knownPlatforms) { const nodeRanges = [ 'node8', 'node10', 'node12', 'node14', 'node16', 'node18', ]; for (const nodeRange of nodeRanges) { const nodeVersion = nodeRangeToNodeVersion(nodeRange); const archs = ['x64']; if (platform === 'win') archs.unshift('x86'); if (platform === 'linux') archs.push('arm64'); // linux-arm64 is needed in multi-arch tests, // so keeping it here as obligatory. but let's // leave compiling for freebsd to end users if (platform === 'freebsd') continue; for (const arch of archs) { if (dontBuild(nodeVersion, platform, arch)) continue; items.push({ nodeRange, platform, arch }); } } } let p = Promise.resolve(); items.forEach((item) => { p = p.then(() => fetch.need(item)); }); p.catch((error) => { if (!error.wasReported) console.log(`> ${error}`); process.exit(2); }); ================================================ FILE: test/test-42-path-related-values/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './project/app.js'; const output = './deploy/app-x64.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input], { stdio: 'inherit', }); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); left = JSON.parse(left); right = JSON.parse(right); for (let obj of [left, right]) { for (let s in obj) { obj[s] = obj[s] .replace('/home/travis/build', '') .replace('/home/travis/.nvm/versions', '') .replace('\\pkg\\test\\test-42-path-related-values', '') .replace('/pkg/test/test-42-path-related-values', '') .replace('app-x64.exe', 'app-x64'); } } function pad(s, width) { const p = width > s.length ? width - s.length : 1; return s + ' '.repeat(p); } console.log('-'.repeat(78)); for (let s in left) { console.log(pad(s, 30), '|', pad(left[s], 36), '|', right[s]); } console.log('-'.repeat(78)); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-42-path-related-values/project/app.js ================================================ 'use strict'; require('./module.js'); ================================================ FILE: test/test-42-path-related-values/project/module.js ================================================ 'use strict'; console.log( JSON.stringify({ __filename: __filename, __dirname: __dirname, 'process.cwd()': process.cwd(), 'process.execPath': process.execPath, 'process.argv[0]': process.argv[0], 'process.argv[1]': process.argv[1], 'process.pkg.entrypoint': process.pkg ? process.pkg.entrypoint : 'undefined', 'process.pkg.defaultEntrypoint': process.pkg ? process.pkg.defaultEntrypoint : 'undefined', 'require.main.filename': require.main.filename, }) ); ================================================ FILE: test/test-46-input/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index'; const newcomers = [ 'test-x-index-linux', 'test-x-index-macos', 'test-x-index-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([input], { stdio: 'inherit' }); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input/test-x-index ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-js/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index.js'; const newcomers = [ 'test-x-index-linux', 'test-x-index-macos', 'test-x-index-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([input], { stdio: 'inherit' }); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-js/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-output/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index'; const exe = process.platform === 'win32' ? '.exe' : ''; const newcomers = ['test-output' + exe]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--output', 'test-output', input], { stdio: 'inherit' }); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-output/test-x-index ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-output-js/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index.js'; const exe = process.platform === 'win32' ? '.exe' : ''; const newcomers = ['test-output' + exe]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--output', 'test-output', input], { stdio: 'inherit' }); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-output-js/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-output-js-exe/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index.js'; const newcomers = ['test-output.exe']; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--output', 'test-output.exe', input], { stdio: 'inherit' }); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-output-js-exe/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-output-target/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index'; const exe = process.platform === 'win32' ? '.exe' : ''; const newcomers = ['test-output' + exe]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--target', target, '--output', 'test-output', input]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-output-target/test-x-index ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-output-target-js/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index.js'; const exe = process.platform === 'win32' ? '.exe' : ''; const newcomers = ['test-output' + exe]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--target', target, '--output', 'test-output', input]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-output-target-js/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-output-target-js-exe/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index.js'; const newcomers = ['test-output.exe']; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--target', target, '--output', 'test-output.exe', input]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-output-target-js-exe/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-output-targets-many/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index'; const newcomers = [ 'test-output-linux', 'test-output-macos', 'test-output-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([ '--target', 'linux,macos,win', '--output', 'test-output', input, ]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-output-targets-many/test-x-index ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-output-targets-many-2/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index'; const newcomers = [ 'test-output-linux', 'test-output-macos', 'test-output-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([ '--target', `${target}-linux,${target}-macos,${target}-win`, '--output', 'test-output', input, ]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-output-targets-many-2/test-x-index ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-output-targets-many-3/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index.js'; const newcomers = [ 'test-output-linux', 'test-output-macos', 'test-output-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([ '--target', 'linux,macos,win', '--output', 'test-output', input, ]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-output-targets-many-3/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-output-targets-many-4/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index.js'; const newcomers = [ 'test-output-linux', 'test-output-macos', 'test-output-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([ '--target', `${target}-linux,${target}-macos,${target}-win`, '--output', 'test-output', input, ]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-output-targets-many-4/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-output-targets-many-5/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index.js'; const newcomers = [ 'test-output.exe-linux', 'test-output.exe-macos', 'test-output.exe-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([ '--target', 'linux,macos,win', '--output', 'test-output.exe', input, ]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-output-targets-many-5/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-output-targets-many-6/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index.js'; const newcomers = [ 'test-output.exe-linux', 'test-output.exe-macos', 'test-output.exe-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([ '--target', `${target}-linux,${target}-macos,${target}-win`, '--output', 'test-output.exe', input, ]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-output-targets-many-6/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-package-json/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './package.json'; const newcomers = [ 'palookaville-linux', 'palookaville-macos', 'palookaville-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([input], { stdio: 'inherit' }); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-package-json/package.json ================================================ { "name": "palookaville", "bin": "test-x-index.js" } ================================================ FILE: test/test-46-input-package-json/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-package-json-dir/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = '.'; const newcomers = [ 'palookaville-linux', 'palookaville-macos', 'palookaville-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([input], { stdio: 'inherit' }); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-package-json-dir/package.json ================================================ { "name": "palookaville", "bin": "test-x-index.js" } ================================================ FILE: test/test-46-input-package-json-dir/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-package-json-dir-scope/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = '.'; const newcomers = [ 'palookaville-linux', 'palookaville-macos', 'palookaville-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([input], { stdio: 'inherit' }); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-package-json-dir-scope/package.json ================================================ { "name": "@org/palookaville", "bin": "test-x-index.js" } ================================================ FILE: test/test-46-input-package-json-dir-scope/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-package-json-outputdir/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = '.'; const newcomers = [ 'out/palookaville-linux', 'out/palookaville-macos', 'out/palookaville-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([input], { stdio: 'inherit' }); utils.filesAfter(before, newcomers); utils.vacuum.sync('out'); ================================================ FILE: test/test-46-input-package-json-outputdir/package.json ================================================ { "name": "palookaville", "bin": "test-x-index.js", "pkg": { "outputPath": "out" } } ================================================ FILE: test/test-46-input-package-json-outputdir/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-package-json-target/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './package.json'; const newcomers = ['palookaville-linux', 'palookaville-macos']; const before = utils.filesBefore(newcomers); utils.pkg.sync([input], { stdio: 'inherit' }); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-package-json-target/package.json ================================================ { "name": "palookaville", "bin": "test-x-index.js", "pkg": { "targets": [ "linux", "macos" ] } } ================================================ FILE: test/test-46-input-package-json-target/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-target/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index'; const exe = { win32: '.exe', linux: '-linux', darwin: '-macos', freebsd: '-freebsd', }[process.platform]; const newcomers = ['test-x-index' + exe]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--target', target, input]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-target/test-x-index ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-target-js/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index.js'; const exe = process.platform === 'win32' ? '.exe' : ''; const newcomers = ['test-x-index' + exe]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--target', target, input]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-target-js/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-target-js-exe/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index.js'; const exe = process.platform === 'win32' ? '.exe' : ''; const newcomers = ['test-x-index' + exe]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--target', target, input]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-target-js-exe/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-targets-many/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index'; const newcomers = [ 'test-x-index-linux', 'test-x-index-macos', 'test-x-index-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--target', 'linux,macos,win', input]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-targets-many/test-x-index ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-targets-many-2/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index'; const newcomers = [ 'test-x-index-linux', 'test-x-index-macos', 'test-x-index-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([ '--target', `${target}-linux,${target}-macos,${target}-win`, input, ]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-targets-many-2/test-x-index ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-targets-many-3/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index.js'; const newcomers = [ 'test-x-index-linux', 'test-x-index-macos', 'test-x-index-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--target', 'linux,macos,win', input]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-targets-many-3/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-targets-many-4/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index.js'; const newcomers = [ 'test-x-index-linux', 'test-x-index-macos', 'test-x-index-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([ '--target', `${target}-linux,${target}-macos,${target}-win`, input, ]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-targets-many-4/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-targets-many-5/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index.js'; const newcomers = [ 'test-x-index-linux', 'test-x-index-macos', 'test-x-index-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--target', 'linux,macos,win', input]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-targets-many-5/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-input-targets-many-6/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index.js'; const newcomers = [ 'test-x-index-linux', 'test-x-index-macos', 'test-x-index-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync([ '--target', `${target}-linux,${target}-macos,${target}-win`, input, ]); utils.filesAfter(before, newcomers); ================================================ FILE: test/test-46-input-targets-many-6/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-multi-arch/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); // only linux-x64 has linux-armv7 counterpart if (process.platform !== 'linux') return; const opposite = { x64: 'armv7', x86: 'armv7', ia32: 'armv7', arm: 'x64' }; const target = opposite[process.arch]; const input = './test-x-index.js'; const output = './test-output.exe'; let right = utils.pkg.sync(['--target', target, '--output', output, input], { stdio: 'pipe', }); assert(right.stdout.indexOf('\x1B\x5B') < 0, 'colors detected'); assert(right.stdout.indexOf('Warning') >= 0); assert(right.stdout.indexOf(target) >= 0); utils.vacuum.sync(output); ================================================ FILE: test/test-46-multi-arch/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-multi-arch-2/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); if ( (function () { // testing armv7-to-armv6 crosscompilation if (process.platform === 'linux' && process.arch === 'arm') return false; // TODO what about armv8? we need to distingish host arch // armv6/armv7/armv8 - not just 'arm' we have now // linux may not have multiarch installed if (process.platform === 'linux') return true; return false; })() ) return; const opposite = { x64: 'x86', x86: 'x64', ia32: 'x64', arm: 'armv6' }; const target = opposite[process.arch]; const input = './test-x-index.js'; const output = './test-output.exe'; let right; utils.pkg.sync(['--target', target, '--output', output, input], { stdio: 'inherit', }); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(right, '42\n'); utils.vacuum.sync(output); ================================================ FILE: test/test-46-multi-arch-2/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-outpath/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index'; const newcomers = [ 'out/test-x-index-linux', 'out/test-x-index-macos', 'out/test-x-index-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--out-path', 'out', input]); utils.filesAfter(before, newcomers); utils.vacuum.sync('out'); ================================================ FILE: test/test-46-outpath/test-x-index ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-outpath-target/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'latest'; const input = './test-x-index'; const exe = { win32: '.exe', linux: '', darwin: '', freebsd: '' }[ process.platform ]; const newcomers = ['out/test-x-index' + exe]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--target', target, '--out-path', 'out', input]); utils.filesAfter(before, newcomers); utils.vacuum.sync('out'); ================================================ FILE: test/test-46-outpath-target/test-x-index ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-46-outpath-targets-many/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const input = './test-x-index'; const newcomers = [ 'out/test-x-index-linux', 'out/test-x-index-macos', 'out/test-x-index-win.exe', ]; const before = utils.filesBefore(newcomers); utils.pkg.sync(['--target', 'linux,macos,win', '--out-path', 'out', input]); utils.filesAfter(before, newcomers); utils.vacuum.sync('out'); ================================================ FILE: test/test-46-outpath-targets-many/test-x-index ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-48-common/main.js ================================================ #!/usr/bin/env node /* eslint-disable no-multi-spaces */ 'use strict'; const assert = require('assert'); const common = require('../../lib-es5/common.js'); function substituteMany(files) { const d = common.retrieveDenominator(files); return files.map((f) => common.substituteDenominator(f, d)); } if (process.platform === 'win32') { assert.strictEqual('c:', common.normalizePath('c:')); assert.strictEqual('C:\\', common.normalizePath('c:\\')); assert.strictEqual('C:\\', common.normalizePath('c:\\\\')); assert.strictEqual('C:\\snapshot', common.normalizePath('c:\\snapshot')); assert.strictEqual('C:\\snapshoter', common.normalizePath('c:\\snapshoter')); assert.strictEqual('C:\\snapshot', common.normalizePath('c:\\snapshot\\')); assert.strictEqual( 'C:\\snapshoter', common.normalizePath('c:\\snapshoter\\') ); assert.strictEqual( 'C:\\snapshot\\foo', common.normalizePath('c:\\snapshot\\\\foo') ); assert.strictEqual( 'C:\\snapshot\\foo\\bar', common.normalizePath('c:\\snapshot\\\\foo\\\\bar\\/\\\\') ); assert.strictEqual(common.insideSnapshot('c:'), false); assert.strictEqual(common.insideSnapshot('c:\\'), false); assert.strictEqual(common.insideSnapshot('c:\\foo'), false); assert.strictEqual(common.insideSnapshot('c:\\foo\\snapshot'), false); assert.strictEqual(common.insideSnapshot('c:\\snapshot'), true); assert.strictEqual(common.insideSnapshot('c:\\snapshoter'), false); assert.strictEqual(common.insideSnapshot('c:\\snapshot\\'), true); assert.strictEqual(common.insideSnapshot('c:\\snapshoter\\'), false); assert.strictEqual(common.insideSnapshot('c:\\snapshot\\\\'), true); assert.strictEqual(common.insideSnapshot('c:\\snapshot\\foo'), true); assert.strictEqual(common.insideSnapshot('c:\\snapshoter\\foo'), false); assert.strictEqual('c:\\', common.stripSnapshot('c:\\')); assert.strictEqual('c:\\\\', common.stripSnapshot('c:\\\\')); assert.strictEqual('C:\\**\\', common.stripSnapshot('c:\\snapshot')); assert.strictEqual('c:\\snapshoter', common.stripSnapshot('c:\\snapshoter')); assert.strictEqual('C:\\**\\', common.stripSnapshot('c:\\snapshot\\')); assert.strictEqual( 'c:\\snapshoter\\', common.stripSnapshot('c:\\snapshoter\\') ); assert.strictEqual( 'C:\\**\\foo', common.stripSnapshot('c:\\snapshot\\\\foo') ); assert.strictEqual( 'C:\\**\\foo\\bar', common.stripSnapshot('c:\\snapshot\\\\foo\\\\bar\\/\\\\') ); assert.strictEqual('C:\\snapshot', common.snapshotify('C:\\')); assert.strictEqual('C:\\snapshot\\foo', common.snapshotify('C:\\foo')); assert.strictEqual( 'C:\\snapshot\\foo\\bar', common.snapshotify('C:\\foo\\bar') ); assert.strictEqual('foo', common.removeUplevels('..\\foo')); assert.strictEqual('foo', common.removeUplevels('..\\..\\foo')); assert.strictEqual('.\\foo', common.removeUplevels('.\\foo')); assert.strictEqual('.', common.removeUplevels('.')); assert.strictEqual('.', common.removeUplevels('..')); assert.strictEqual('.', common.removeUplevels('..\\..')); assert.deepStrictEqual( substituteMany([ 'C:\\long\\haired\\freaky\\people', 'C:\\long\\haired\\aliens', ]), ['C:\\freaky\\people', 'C:\\aliens'] ); assert.deepStrictEqual( substituteMany([ 'C:\\long\\haired\\freaky\\people', 'C:\\long\\hyphen\\sign', ]), ['C:\\haired\\freaky\\people', 'C:\\hyphen\\sign'] ); assert.deepStrictEqual( substituteMany([ 'C:\\long\\haired\\freaky\\people', 'D:\\long\\hyphen\\sign', ]), ['C:\\long\\haired\\freaky\\people', 'D:\\long\\hyphen\\sign'] ); } else { assert.strictEqual('/', common.normalizePath('/')); assert.strictEqual('/', common.normalizePath('//')); assert.strictEqual('/snapshot', common.normalizePath('/snapshot')); assert.strictEqual('/snapshoter', common.normalizePath('/snapshoter')); assert.strictEqual('/snapshot', common.normalizePath('/snapshot/')); assert.strictEqual('/snapshoter', common.normalizePath('/snapshoter/')); assert.strictEqual('/snapshot/foo', common.normalizePath('/snapshot//foo')); assert.strictEqual( '/snapshot/foo/bar', common.normalizePath('/snapshot//foo//bar/\\//') ); assert.strictEqual(common.insideSnapshot(''), false); assert.strictEqual(common.insideSnapshot('/'), false); assert.strictEqual(common.insideSnapshot('/foo'), false); assert.strictEqual(common.insideSnapshot('/foo/snapshot'), false); assert.strictEqual(common.insideSnapshot('/snapshot'), true); assert.strictEqual(common.insideSnapshot('/snapshoter'), false); assert.strictEqual(common.insideSnapshot('/snapshot/'), true); assert.strictEqual(common.insideSnapshot('/snapshoter/'), false); assert.strictEqual(common.insideSnapshot('/snapshot//'), true); assert.strictEqual(common.insideSnapshot('/snapshot/foo'), true); assert.strictEqual(common.insideSnapshot('/snapshoter/foo'), false); assert.strictEqual('/', common.stripSnapshot('/')); assert.strictEqual('//', common.stripSnapshot('//')); assert.strictEqual('/**/', common.stripSnapshot('/snapshot')); assert.strictEqual('/snapshoter', common.stripSnapshot('/snapshoter')); assert.strictEqual('/**/', common.stripSnapshot('/snapshot/')); assert.strictEqual('/snapshoter/', common.stripSnapshot('/snapshoter/')); assert.strictEqual('/**/foo', common.stripSnapshot('/snapshot//foo')); assert.strictEqual( '/**/foo/bar', common.stripSnapshot('/snapshot//foo//bar/\\//') ); assert.strictEqual('/snapshot', common.snapshotify('/')); assert.strictEqual('/snapshot/foo', common.snapshotify('/foo')); assert.strictEqual('/snapshot/foo/bar', common.snapshotify('/foo/bar')); assert.strictEqual('foo', common.removeUplevels('../foo')); assert.strictEqual('foo', common.removeUplevels('../../foo')); assert.strictEqual('./foo', common.removeUplevels('./foo')); assert.strictEqual('.', common.removeUplevels('.')); assert.strictEqual('.', common.removeUplevels('..')); assert.strictEqual('.', common.removeUplevels('../..')); assert.deepStrictEqual( substituteMany(['/long/haired/freaky/people', '/long/haired/aliens']), ['/freaky/people', '/aliens'] ); assert.deepStrictEqual( substituteMany(['/long/haired/freaky/people', '/long/hyphen/sign']), ['/haired/freaky/people', '/hyphen/sign'] ); } ================================================ FILE: test/test-50-api/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let right; utils.mkdirp.sync(path.dirname(output)); // calling twice require('../../') .exec(['--target', target, '--output', output, input]) .then(function () { return require('../../') .exec(['--target', target, '--output', output, input]) .then(function () { right = utils.spawn.sync(output, [], {}); assert.strictEqual(right, '42\n'); utils.vacuum.sync(output); }); }) .catch(function (error) { console.error(error); process.exit(2); }); ================================================ FILE: test/test-50-api/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-50-arguments/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let right; utils.mkdirp.sync(path.dirname(output)); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync(output, ['42'], {}); assert.strictEqual(right, '42\n'); right = utils.spawn.sync(output, ['-ft'], {}); assert.strictEqual(right, '-ft\n'); right = utils.spawn.sync(output, ['--fourty-two'], {}); assert.strictEqual(right, '--fourty-two\n'); utils.vacuum.sync(output); ================================================ FILE: test/test-50-arguments/test-x-index.js ================================================ 'use strict'; console.log(process.argv[2]); ================================================ FILE: test/test-50-ast-parsing/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './test-output.exe'; const data = './test-y-data.txt'; if (/^(node|v)?0/.test(target)) return; if (/^(node|v)?4/.test(target)) return; let left, right; left = fs .readFileSync(data, 'utf8') .split('\n') .filter(function (line) { return line.indexOf('/***/ ') >= 0; }) .map(function (line) { return line.split('/***/ ')[1].replace(/['`]/g, '"'); }) .join('\n') + '\n'; utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.deepStrictEqual(left.split(/(\r|\n)+/), right.split(/(\r|\n)+/)); utils.vacuum.sync(output); ================================================ FILE: test/test-50-ast-parsing/test-x-index.js ================================================ 'use strict'; const fs = require('fs'); const detector = require('../../lib-es5/detector.js'); const body = fs.readFileSync('./test-y-data.txt', 'utf8'); detector.detect(body, function (node, trying) { let p; p = detector.visitorSuccessful(node, true); if (p) { if (trying) { console.log('try { ' + p + '; } catch (_) {}'); } else { console.log(p + ';'); } return false; } // TODO maybe NONLITERAL and USESCWD? return true; }); ================================================ FILE: test/test-50-ast-parsing/test-y-data.txt ================================================ // TODO import "barbos0" once it works /***/ import foo1 from "barbos0"; /***/ import { foo2, foo3 } from "barbos0"; /***/ import foo4, { foo5 as foo5a } from "barbos0"; function hellee(a, b, c) { require.resolve(); /***/ require.resolve("barbos1"); /***/ require.resolve(`barbos1`); /***/ require.resolve(`barbos1`, `must-exclude1`); /***/ require.resolve("barbos1", "must-exclude1"); /***/ require.resolve("barbos1", "may-exclude1"); /***/ require.resolve("barbos1", "unknown1"); require(); /***/ require("barbos2"); /***/ require(`barbos2`); /***/ require(`barbos2`, `must-exclude2`); /***/ require("barbos2", "must-exclude2"); /***/ require("barbos2", "may-exclude2"); /***/ require("barbos2", "unknown2"); path.join(); path.join(__dirname); /***/ path.join(__dirname, "file"); /***/ path.join(__dirname, `file`); // TODO path.join(__dirname + "/file"); return { result: a + b - c }; } function helleeTry(a, b, c) { try { require.resolve(); } catch (_) {} /***/ try { require.resolve("barbos1"); } catch (_) {} /***/ try { require.resolve(`barbos1`); } catch (_) {} /***/ try { require.resolve(`barbos1`, `must-exclude1`); } catch (_) {} /***/ try { require.resolve("barbos1", "must-exclude1"); } catch (_) {} /***/ try { require.resolve("barbos1", "may-exclude1"); } catch (_) {} /***/ try { require.resolve("barbos1", "unknown1"); } catch (_) {} try { require(); } catch (_) {} /***/ try { require("barbos2"); } catch (_) {} /***/ try { require(`barbos2`); } catch (_) {} /***/ try { require(`barbos2`, `must-exclude2`); } catch (_) {} /***/ try { require("barbos2", "must-exclude2"); } catch (_) {} /***/ try { require("barbos2", "may-exclude2"); } catch (_) {} /***/ try { require("barbos2", "unknown2"); } catch (_) {} try { path.join(); } catch (_) {} try { path.join(__dirname); } catch (_) {} /***/ try { path.join(__dirname, "file"); } catch (_) {} // TODO path.join(__dirname + "/file"); return { result: a + b - c }; } function helluu(a, b, c) { return { result: function() { var require = {}; var path = {}; require.resolve(); /***/ require.resolve("barbos1"); /***/ require.resolve(`barbos1`); /***/ require.resolve(`barbos1`, `must-exclude1`); /***/ require.resolve("barbos1", "must-exclude1"); /***/ require.resolve("barbos1", "may-exclude1"); /***/ require.resolve("barbos1", "unknown1"); require(); /***/ require("barbos2"); /***/ require(`barbos2`); /***/ require(`barbos2`, `must-exclude2`); /***/ require("barbos2", "must-exclude2"); /***/ require("barbos2", "may-exclude2"); /***/ require("barbos2", "unknown2"); path.join(); path.join(__dirname); /***/ path.join(__dirname, "file"); /***/ path.join(__dirname, `file`); // TODO path.join(__dirname + "/file"); return { result: a + b - c }; } } } function helluuTry(a, b, c) { return { result: function() { var require = {}; var path = {}; try { require.resolve(); } catch (_) {} /***/ try { require.resolve("barbos1"); } catch (_) {} /***/ try { require.resolve(`barbos1`); } catch (_) {} /***/ try { require.resolve(`barbos1`, `must-exclude1`); } catch (_) {} /***/ try { require.resolve("barbos1", "must-exclude1"); } catch (_) {} /***/ try { require.resolve("barbos1", "may-exclude1"); } catch (_) {} /***/ try { require.resolve("barbos1", "unknown1"); } catch (_) {} try { require(); } catch (_) {} /***/ try { require("barbos2"); } catch (_) {} /***/ try { require(`barbos2`); } catch (_) {} /***/ try { require(`barbos2`, `must-exclude2`); } catch (_) {} /***/ try { require("barbos2", "must-exclude2"); } catch (_) {} /***/ try { require("barbos2", "may-exclude2"); } catch (_) {} /***/ try { require("barbos2", "unknown2"); } catch (_) {} try { path.join(); } catch (_) {} try { path.join(__dirname); } catch (_) {} /***/ try { path.join(__dirname, "file"); } catch (_) {} /***/ try { path.join(__dirname, `file`); } catch (_) {} // TODO path.join(__dirname + "/file"); return { result: a + b - c }; } } } console.log( hellee(1, 2, 3).result, helluu(4, 5, 6).result ); var inheritedDataKeys = (function() { var obj = {}; function hasProp(o, k) { return true; } enumeration: for (var key in obj) { if (!hasProp.call(obj, key)) { continue enumeration; } } })(); var INFINITY = 1 / 0; var NEGATIVE_INFINITY = -1 / 0; var group_names = [ , 'whitespace' // INTENTIONAL COMMA! , 'terminator' , 'string' , 'comment' , 'identifier' , 'preprocess' , 'operator' , 'invalid' ]; ================================================ FILE: test/test-50-ast-parsing-2/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; const standard = 'stdout'; let left, right; left = fs .readFileSync(input, 'utf8') .split('\n') .filter(function (line) { return line.indexOf('/**/') >= 0; }) .map(function (line) { return line.split('/**/')[1].trim(); }) .join('\n') + '\n'; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync( ['--debug', '--target', target, '--output', output, input], inspect ); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); const rightLines = []; right.split('\n').some(function (line) { let s = line.split("Cannot resolve '")[1]; if (s) { rightLines.push(s.slice(0, -')'.length)); return; } s = line.split('Path.resolve(')[1]; if (s) { rightLines.push(s.slice(0, -') is ambiguous'.length)); } }); right = rightLines.join('\n') + '\n'; assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-ast-parsing-2/test-x-index.js ================================================ 'use strict'; var path = require('path'); var async = 'async'; var config = 'config'; var i = 0; require(/**/ async /**/); require(/**/ async.toString() /**/); require(/**/ async.toString('utf8') /**/); require(/**/ path.resolve(process.cwd(), config) /**/); require(/**/ async.slice().toString('utf8') /**/); require(/**/ async.slice(0).toString('utf8') /**/); require(/**/ async.slice(1.5).toString('utf8') /**/); require(/**/ async + '.js' /**/); require(/**/ async + 75.25 /**/); require(/**/ __dirname + '/' + async /**/); // eslint-disable-line no-path-concat require(/**/ __dirname + '/' + async + 35.5 /**/); // eslint-disable-line no-path-concat require(/**/ [async, 'js'].join('.') /**/); // TODO require({ async: "js" }.join(".")); require(/**/ async[0] /**/); require(/**/ async[i] /**/); require(/**/ process.env.LATER_COV ? './later-cov' : './later' /**/); path.resolve(/**/ '123' /**/); path.resolve(/**/ '123', '456' /**/); ================================================ FILE: test/test-50-bakery/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, 'undefined\n'); assert.strictEqual(right, 'undefined\n'); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-bakery/test-x-index.js ================================================ 'use strict'; console.log(typeof gc); ================================================ FILE: test/test-50-bakery-2/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', ['--expose-gc', path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync([ '--target', target, '--options', 'expose-gc', '--output', output, input, ]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, 'function\n'); assert.strictEqual(right, 'function\n'); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-bakery-2/test-x-index.js ================================================ 'use strict'; console.log(typeof gc); ================================================ FILE: test/test-50-bakery-3/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', ['--v8-options'], { cwd: path.dirname(input) }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), ['--v8-options'], { cwd: path.dirname(output), env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS' }, }); assert(left.indexOf('--expose_gc') >= 0 || left.indexOf('--expose-gc') >= 0); assert(right.indexOf('--expose_gc') >= 0 || right.indexOf('--expose-gc') >= 0); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-bakery-3/test-x-index.js ================================================ 'use strict'; console.log('should not be executed'); ================================================ FILE: test/test-50-bakery-4/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; if (/^(node|v)?0/.test(target)) return; if (/^(node|v)?4/.test(target)) return; if (/^(node|v)?6/.test(target)) return; if (/^(node|v)?8/.test(target)) return; let left; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', ['--v8-options'], { cwd: path.dirname(input) }); for (const option of ['v8-options', 'v8_options']) { let right; utils.pkg.sync([ '--target', target, '--options', option, '--output', output, input, ]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert(left.indexOf('--expose_gc') >= 0 || left.indexOf('--expose-gc') >= 0); assert( right.indexOf('--expose_gc') >= 0 || right.indexOf('--expose-gc') >= 0 ); } utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-bakery-4/test-x-index.js ================================================ 'use strict'; console.log('should not be executed'); ================================================ FILE: test/test-50-bakery-fetch/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); const fetch = require('pkg-fetch'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; let right; fetch .need({ nodeRange: target, platform: fetch.system.hostPlatform, arch: fetch.system.hostArch, }) .then(function (needed) { if (process.platform === 'darwin') { utils.spawn.sync( 'codesign', ['-fds', '-', './' + path.basename(needed)], { cwd: path.dirname(needed) } ); } right = utils.spawn.sync( './' + path.basename(needed), ['--expose-gc', '-e', 'if (global.gc) console.log("ok");'], { cwd: path.dirname(needed), env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS' } } ); assert.strictEqual(right, 'ok\n'); }) .catch(function (error) { console.error(`> ${error.message}`); process.exit(2); }); ================================================ FILE: test/test-50-can-include-addon/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; const standard = 'stdout'; let right; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync( ['--target', target, '--output', output, input], inspect ); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); right = right.replace(/\\/g, '/'); assert(right.indexOf('test-50-can-include-addon/time.node') === -1); assert(right.indexOf('path-to-executable/time.node') === -1); utils.vacuum.sync(output); ================================================ FILE: test/test-50-can-include-addon/test-x-index.js ================================================ 'use strict'; require('./time.node'); ================================================ FILE: test/test-50-can-include-addon/time.node ================================================ module.exports = 'test'; ================================================ FILE: test/test-50-cannot-css-script/assets/animate.css ================================================ module.exports = require('path').basename(__filename); ================================================ FILE: test/test-50-cannot-css-script/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const output = './test-output.exe'; const standard = 'stdout'; let right; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync(['--target', target, '--output', output, '.'], inspect); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); assert(right.indexOf("Non-javascript file is specified in 'scripts'") >= 0); assert(right.indexOf('animate.css') >= 0); utils.vacuum.sync(output); ================================================ FILE: test/test-50-cannot-css-script/package.json ================================================ { "bin": "test-x-index.js", "pkg": { "scripts": [ "assets" ] } } ================================================ FILE: test/test-50-cannot-css-script/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-50-cannot-include-df/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; const standard = 'stdout'; let right; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync( ['--target', target, '--output', output, input], inspect ); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); right = right.replace(/\\/g, '/'); assert(right.indexOf('node_modules/some-package/fromFile') >= 0); assert(right.indexOf('path-to-executable/toFile') >= 0); utils.vacuum.sync(output); ================================================ FILE: test/test-50-cannot-include-df/test-x-index.js ================================================ 'use strict'; require('some-package'); ================================================ FILE: test/test-50-chdir-env-var/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let right; utils.pkg.sync(['--target', target, '--output', output, input], { env: { CHDIR: 'source', PATH: process.env.PATH, }, }); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname('source/' + output), }); assert.strictEqual(right, 'ok\n'); utils.vacuum.sync(path.dirname('source/' + output)); ================================================ FILE: test/test-50-chdir-env-var/source/test-x-index.js ================================================ 'use strict'; console.log('ok'); ================================================ FILE: test/test-50-class-to-string/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './test-output.exe'; if (/^(node|v)?0/.test(target)) return; let right; utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(right, 'ok\n'); utils.vacuum.sync(output); ================================================ FILE: test/test-50-class-to-string/test-x-index.js ================================================ 'use strict'; const Class = class {}; // test if Class.toString() segfaults // or returns incorrect value (#62) const cts = Class.toString(); if (cts.indexOf('class {}') >= 0) { console.log('ok'); } ================================================ FILE: test/test-50-config-log/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; const standard = 'stdout'; let right; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync( ['--target', target, '--output', output, input], inspect ); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); assert(right.indexOf('stylus options to resolve imports') >= 0); utils.vacuum.sync(output); ================================================ FILE: test/test-50-config-log/test-x-index.js ================================================ 'use strict'; require('stylus'); ================================================ FILE: test/test-50-console-trace/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let right; utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), stdio: 'pipe', expect: 0, }); function extractFileName(line) { let m = line.match(/^.+\((.+):\d+:\d+\)$/); if (m) return m[1]; m = line.match(/^.+\((.+):\d+\)$/); if (m) return m[1]; m = line.match(/^.+\((.+)\)$/); if (m) return m[1]; return undefined; } right = right.stderr.split('\n'); var a = right[0]; var b = extractFileName(right[2]); var c = extractFileName(right[3]); assert.strictEqual(a, b); assert.strictEqual(c, 'pkg/prelude/bootstrap.js'); utils.vacuum.sync(output); ================================================ FILE: test/test-50-console-trace/test-x-index.js ================================================ 'use strict'; console.error(__filename); console.trace(); ================================================ FILE: test/test-50-corrupt-executable/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './test-output.exe'; let right; // on macos damaging the binary should happen prior to the signature utils.pkg.sync([ '--no-signature', '--target', target, '--output', output, input, ]); const damage = fs.readFileSync(output); const boundary = 4096; damage[damage.length - 2 * boundary - 10] = 0x2; damage[damage.length - 3 * boundary - 10] = 0x2; damage[damage.length - 4 * boundary - 10] = 0x2; damage[damage.length - 2 * boundary + 10] = 0x2; damage[damage.length - 3 * boundary + 10] = 0x2; damage[damage.length - 4 * boundary + 10] = 0x2; fs.writeFileSync(output, damage); if (process.platform === 'darwin') { utils.spawn.sync( 'codesign', ['--no-strict', '-fs', '-', './' + path.basename(output)], { cwd: path.dirname(output), } ); } right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), stdio: 'pipe', expect: 1, }); assert.strictEqual(right.stdout, ''); assert( right.stderr.indexOf('Invalid') >= 0 || right.stderr.indexOf('ILLEGAL') >= 0 || right.stderr.indexOf('SyntaxError') >= 0 ); utils.vacuum.sync(output); ================================================ FILE: test/test-50-corrupt-executable/test-x-index.js ================================================ 'use strict'; console.log('ok'); ================================================ FILE: test/test-50-debug/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; utils.pkg.sync(['--target', target, '--output', output, input]); utils.spawn.sync('./' + path.basename(output), ['--debug'], { cwd: path.dirname(output), env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS' }, stdio: 'pipe', expect: 9, }); utils.vacuum.sync(output); ================================================ FILE: test/test-50-debug/test-x-index.js ================================================ 'use strict'; setTimeout(function () { console.log('ok'); }, 3000); ================================================ FILE: test/test-50-error-source-position/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './test-output.exe'; let right; utils.pkg.sync(['--public', '--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), stdio: 'pipe', expect: 1, }); if (!/^(node|v)?0/.test(target)) { assert(right.stderr.indexOf('x.parse is not a function') >= 0); } const errorPointer = 'x.parse();' + require('os').EOL + ' ^'; assert(right.stderr.indexOf(errorPointer) >= 0); utils.vacuum.sync(output); ================================================ FILE: test/test-50-error-source-position/test-x-index.js ================================================ 'use strict'; var x = {}; x.parse(); // var x = {}; // x.parse(); // var x = {}; // x.parse(); // var x = {}; // x.parse(); // var x = {}; // x.parse(); // var x = {}; // x.parse(); ================================================ FILE: test/test-50-extensions/.eslintrc.json ================================================ { "parserOptions": { "sourceType": "module" } } ================================================ FILE: test/test-50-extensions/main.js ================================================ #!/usr/bin/env node /* eslint-disable strict */ 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let left, right; left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--public', '--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-extensions/test-x-index.js ================================================ /* eslint-disable no-underscore-dangle */ var Module = require('module'); var fs = require('fs'); Module._extensions['.js'] = function (module, filename) { var content = fs.readFileSync(filename, 'utf8'); // emulating babel-register content = content.replace( "import x from './test-z-sub.js';", "require('./test-z-sub.js');" ); module._compile(content, filename); }; require('./test-y-esnext.js'); ================================================ FILE: test/test-50-extensions/test-y-esnext.js ================================================ /* eslint-disable no-unused-vars */ import x from './test-z-sub.js'; ================================================ FILE: test/test-50-extensions/test-z-sub.js ================================================ console.log(42); ================================================ FILE: test/test-50-for-await-of/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './test-output.exe'; if (/^(node|v)?0/.test(target)) return; if (/^(node|v)?4/.test(target)) return; if (/^(node|v)?6/.test(target)) return; if (/^(node|v)?8/.test(target)) return; let right; utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(right, '1\n2\n3\n4\n5\n'); utils.vacuum.sync(output); ================================================ FILE: test/test-50-for-await-of/test-x-index.js ================================================ 'use strict'; class AsyncIterator { constructor() { this.limit = 5; this.current = 0; } next() { this.current += 1; let done = this.current > this.limit; return Promise.resolve({ value: done ? undefined : this.current, done, }); } [Symbol.asyncIterator]() { return this; } } // The function does have an await (in the for-await-of loop), ESLint just doesn't seem to detect it /* eslint-disable require-await */ async function t() { /* eslint-enable require-await */ let it = new AsyncIterator(); for await (let x of it) { console.log(x); } } t(); ================================================ FILE: test/test-50-fs-runtime-layer/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const output = './run-time/test-output.exe'; if (process.arch === 'arm') return; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', ['test-x-index.js']); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); left = left.split('\n'); right = right.split('\n'); // right may have less lines, premature exit, // less trusted, so using left.length here for (let i = 0; i < left.length; i += 1) { if (left[i] !== right[i]) { console.log('line', i); console.log('<>right>>\n' + right); throw new Error('Assertion'); } } utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-fs-runtime-layer/package.json ================================================ { "bin": "test-x-index.js", "pkg": { "assets": [ "test-z-asset-A.css", "test-z-asset-B.css" ] } } ================================================ FILE: test/test-50-fs-runtime-layer/test-x-index.js ================================================ 'use strict'; require('./test-x1-index.js'); setTimeout(function () { require('./test-x2-index.js'); setTimeout(function () { require('./test-x3-index.js'); }, 100); }, 100); ================================================ FILE: test/test-50-fs-runtime-layer/test-x1-index.js ================================================ /* eslint-disable brace-style */ /* eslint-disable no-path-concat */ 'use strict'; var fs = require('fs'); var path = require('path'); var windows = process.platform === 'win32'; var theRequireContentA = './test-z-asset-A.css'; var theRequireContentB = 'test-z-asset-B.css'; function firstLowerCase(s) { return s.slice(0, 1).toLowerCase() + s.slice(1); } function firstUpperCase(s) { return s.slice(0, 1).toUpperCase() + s.slice(1); } console.log( [ fs.readFileSync(path.join(__dirname, theRequireContentA)), fs.readFileSync(__dirname + path.sep + theRequireContentB), fs.readFileSync(__dirname + '/' + theRequireContentB), windows ? fs.readFileSync(__dirname + '/\\' + theRequireContentB) : '', windows ? fs.readFileSync(__dirname + '\\' + theRequireContentB) : '', windows ? fs.readFileSync(__dirname + '\\/' + theRequireContentB) : '', fs.readFileSync(firstLowerCase(path.join(__dirname, theRequireContentA))), fs.readFileSync(firstLowerCase(__dirname + path.sep + theRequireContentB)), fs.readFileSync(firstLowerCase(__dirname + '/' + theRequireContentB)), windows ? fs.readFileSync(firstLowerCase(__dirname + '/\\' + theRequireContentB)) : '', windows ? fs.readFileSync(firstLowerCase(__dirname + '\\' + theRequireContentB)) : '', windows ? fs.readFileSync(firstLowerCase(__dirname + '\\/' + theRequireContentB)) : '', fs.readFileSync(firstUpperCase(path.join(__dirname, theRequireContentA))), fs.readFileSync(firstUpperCase(__dirname + path.sep + theRequireContentB)), fs.readFileSync(firstUpperCase(__dirname + '/' + theRequireContentB)), windows ? fs.readFileSync(firstUpperCase(__dirname + '/\\' + theRequireContentB)) : '', windows ? fs.readFileSync(firstUpperCase(__dirname + '\\' + theRequireContentB)) : '', windows ? fs.readFileSync(firstUpperCase(__dirname + '\\/' + theRequireContentB)) : '', // fs.readdirSync(__dirname).length > 0, fs.readdirSync(path.dirname(__dirname)).length > 0, fs.readdirSync(path.dirname(path.dirname(__dirname))).length > 0, fs.readdirSync(firstLowerCase(__dirname)).length > 0, fs.readdirSync(firstLowerCase(path.dirname(__dirname))).length > 0, fs.readdirSync(firstLowerCase(path.dirname(path.dirname(__dirname)))) .length > 0, fs.readdirSync(firstUpperCase(__dirname)).length > 0, fs.readdirSync(firstUpperCase(path.dirname(__dirname))).length > 0, fs.readdirSync(firstUpperCase(path.dirname(path.dirname(__dirname)))) .length > 0, // fs.existsSync(path.join(__dirname, theRequireContentA)), fs.existsSync(__dirname + path.sep + theRequireContentB), fs.existsSync(__dirname + '/' + theRequireContentB), windows ? fs.existsSync(__dirname + '/\\' + theRequireContentB) : '', windows ? fs.existsSync(__dirname + '\\' + theRequireContentB) : '', windows ? fs.existsSync(__dirname + '\\/' + theRequireContentB) : '', fs.existsSync(firstLowerCase(path.join(__dirname, theRequireContentA))), fs.existsSync(firstLowerCase(__dirname + path.sep + theRequireContentB)), fs.existsSync(firstLowerCase(__dirname + '/' + theRequireContentB)), windows ? fs.existsSync(firstLowerCase(__dirname + '/\\' + theRequireContentB)) : '', windows ? fs.existsSync(firstLowerCase(__dirname + '\\' + theRequireContentB)) : '', windows ? fs.existsSync(firstLowerCase(__dirname + '\\/' + theRequireContentB)) : '', fs.existsSync(firstUpperCase(path.join(__dirname, theRequireContentA))), fs.existsSync(firstUpperCase(__dirname + path.sep + theRequireContentB)), fs.existsSync(firstUpperCase(__dirname + '/' + theRequireContentB)), windows ? fs.existsSync(firstUpperCase(__dirname + '/\\' + theRequireContentB)) : '', windows ? fs.existsSync(firstUpperCase(__dirname + '\\' + theRequireContentB)) : '', windows ? fs.existsSync(firstUpperCase(__dirname + '\\/' + theRequireContentB)) : '', // fs.existsSync(path.join(__dirname, theRequireContentA + '-no-such')), fs.existsSync(__dirname + path.sep + theRequireContentB + '-no-such'), fs.existsSync(__dirname + '/' + theRequireContentB + '-no-such'), windows ? fs.existsSync(__dirname + '/\\' + theRequireContentB + '-no-such') : '', windows ? fs.existsSync(__dirname + '\\' + theRequireContentB + '-no-such') : '', windows ? fs.existsSync(__dirname + '\\/' + theRequireContentB + '-no-such') : '', fs.existsSync( firstLowerCase(path.join(__dirname, theRequireContentA + '-no-such')) ), fs.existsSync( firstLowerCase(__dirname + path.sep + theRequireContentB + '-no-such') ), fs.existsSync( firstLowerCase(__dirname + '/' + theRequireContentB + '-no-such') ), windows ? fs.existsSync( firstLowerCase(__dirname + '/\\' + theRequireContentB + '-no-such') ) : '', windows ? fs.existsSync( firstLowerCase(__dirname + '\\' + theRequireContentB + '-no-such') ) : '', windows ? fs.existsSync( firstLowerCase(__dirname + '\\/' + theRequireContentB + '-no-such') ) : '', fs.existsSync( firstUpperCase(path.join(__dirname, theRequireContentA + '-no-such')) ), fs.existsSync( firstUpperCase(__dirname + path.sep + theRequireContentB + '-no-such') ), fs.existsSync( firstUpperCase(__dirname + '/' + theRequireContentB + '-no-such') ), windows ? fs.existsSync( firstUpperCase(__dirname + '/\\' + theRequireContentB + '-no-such') ) : '', windows ? fs.existsSync( firstUpperCase(__dirname + '\\' + theRequireContentB + '-no-such') ) : '', windows ? fs.existsSync( firstUpperCase(__dirname + '\\/' + theRequireContentB + '-no-such') ) : '', // fs.accessSync(path.join(__dirname, theRequireContentA)), fs.accessSync(__dirname + path.sep + theRequireContentB), fs.accessSync(__dirname + '/' + theRequireContentB), windows ? fs.accessSync(__dirname + '/\\' + theRequireContentB) : '', windows ? fs.accessSync(__dirname + '\\' + theRequireContentB) : '', windows ? fs.accessSync(__dirname + '\\/' + theRequireContentB) : '', fs.accessSync(firstLowerCase(path.join(__dirname, theRequireContentA))), fs.accessSync(firstLowerCase(__dirname + path.sep + theRequireContentB)), fs.accessSync(firstLowerCase(__dirname + '/' + theRequireContentB)), windows ? fs.accessSync(firstLowerCase(__dirname + '/\\' + theRequireContentB)) : '', windows ? fs.accessSync(firstLowerCase(__dirname + '\\' + theRequireContentB)) : '', windows ? fs.accessSync(firstLowerCase(__dirname + '\\/' + theRequireContentB)) : '', fs.accessSync(firstUpperCase(path.join(__dirname, theRequireContentA))), fs.accessSync(firstUpperCase(__dirname + path.sep + theRequireContentB)), fs.accessSync(firstUpperCase(__dirname + '/' + theRequireContentB)), windows ? fs.accessSync(firstUpperCase(__dirname + '/\\' + theRequireContentB)) : '', windows ? fs.accessSync(firstUpperCase(__dirname + '\\' + theRequireContentB)) : '', windows ? fs.accessSync(firstUpperCase(__dirname + '\\/' + theRequireContentB)) : '', // fs.statSync(path.join(__dirname, theRequireContentA)).mode, fs.statSync(__dirname + path.sep + theRequireContentB).mode, fs.statSync(__dirname + '/' + theRequireContentB).mode, windows ? fs.statSync(__dirname + '/\\' + theRequireContentB).mode : '', windows ? fs.statSync(__dirname + '\\' + theRequireContentB).mode : '', windows ? fs.statSync(__dirname + '\\/' + theRequireContentB).mode : '', fs.statSync(firstLowerCase(path.join(__dirname, theRequireContentA))).mode, fs.statSync(firstLowerCase(__dirname + path.sep + theRequireContentB)).mode, fs.statSync(firstLowerCase(__dirname + '/' + theRequireContentB)).mode, windows ? fs.statSync(firstLowerCase(__dirname + '/\\' + theRequireContentB)).mode : '', windows ? fs.statSync(firstLowerCase(__dirname + '\\' + theRequireContentB)).mode : '', windows ? fs.statSync(firstLowerCase(__dirname + '\\/' + theRequireContentB)).mode : '', fs.statSync(firstUpperCase(path.join(__dirname, theRequireContentA))).mode, fs.statSync(firstUpperCase(__dirname + path.sep + theRequireContentB)).mode, fs.statSync(firstUpperCase(__dirname + '/' + theRequireContentB)).mode, windows ? fs.statSync(firstUpperCase(__dirname + '/\\' + theRequireContentB)).mode : '', windows ? fs.statSync(firstUpperCase(__dirname + '\\' + theRequireContentB)).mode : '', windows ? fs.statSync(firstUpperCase(__dirname + '\\/' + theRequireContentB)).mode : '', // fs.statSync(path.join(__dirname, theRequireContentA)).isFile(), fs.statSync(__dirname + path.sep + theRequireContentB).isFile(), fs.statSync(__dirname + '/' + theRequireContentB).isFile(), windows ? fs.statSync(__dirname + '/\\' + theRequireContentB).isFile() : '', windows ? fs.statSync(__dirname + '\\' + theRequireContentB).isFile() : '', windows ? fs.statSync(__dirname + '\\/' + theRequireContentB).isFile() : '', fs .statSync(firstLowerCase(path.join(__dirname, theRequireContentA))) .isFile(), fs .statSync(firstLowerCase(__dirname + path.sep + theRequireContentB)) .isFile(), fs.statSync(firstLowerCase(__dirname + '/' + theRequireContentB)).isFile(), windows ? fs .statSync(firstLowerCase(__dirname + '/\\' + theRequireContentB)) .isFile() : '', windows ? fs .statSync(firstLowerCase(__dirname + '\\' + theRequireContentB)) .isFile() : '', windows ? fs .statSync(firstLowerCase(__dirname + '\\/' + theRequireContentB)) .isFile() : '', fs .statSync(firstUpperCase(path.join(__dirname, theRequireContentA))) .isFile(), fs .statSync(firstUpperCase(__dirname + path.sep + theRequireContentB)) .isFile(), fs.statSync(firstUpperCase(__dirname + '/' + theRequireContentB)).isFile(), windows ? fs .statSync(firstUpperCase(__dirname + '/\\' + theRequireContentB)) .isFile() : '', windows ? fs .statSync(firstUpperCase(__dirname + '\\' + theRequireContentB)) .isFile() : '', windows ? fs .statSync(firstUpperCase(__dirname + '\\/' + theRequireContentB)) .isFile() : '', // fs.statSync(path.join(__dirname, theRequireContentA)).isDirectory(), fs.statSync(__dirname + path.sep + theRequireContentB).isDirectory(), fs.statSync(__dirname + '/' + theRequireContentB).isDirectory(), windows ? fs.statSync(__dirname + '/\\' + theRequireContentB).isDirectory() : '', windows ? fs.statSync(__dirname + '\\' + theRequireContentB).isDirectory() : '', windows ? fs.statSync(__dirname + '\\/' + theRequireContentB).isDirectory() : '', fs .statSync(firstLowerCase(path.join(__dirname, theRequireContentA))) .isDirectory(), fs .statSync(firstLowerCase(__dirname + path.sep + theRequireContentB)) .isDirectory(), fs .statSync(firstLowerCase(__dirname + '/' + theRequireContentB)) .isDirectory(), windows ? fs .statSync(firstLowerCase(__dirname + '/\\' + theRequireContentB)) .isDirectory() : '', windows ? fs .statSync(firstLowerCase(__dirname + '\\' + theRequireContentB)) .isDirectory() : '', windows ? fs .statSync(firstLowerCase(__dirname + '\\/' + theRequireContentB)) .isDirectory() : '', fs .statSync(firstUpperCase(path.join(__dirname, theRequireContentA))) .isDirectory(), fs .statSync(firstUpperCase(__dirname + path.sep + theRequireContentB)) .isDirectory(), fs .statSync(firstUpperCase(__dirname + '/' + theRequireContentB)) .isDirectory(), windows ? fs .statSync(firstUpperCase(__dirname + '/\\' + theRequireContentB)) .isDirectory() : '', windows ? fs .statSync(firstUpperCase(__dirname + '\\' + theRequireContentB)) .isDirectory() : '', windows ? fs .statSync(firstUpperCase(__dirname + '\\/' + theRequireContentB)) .isDirectory() : '', // fs.lstatSync(path.join(__dirname, theRequireContentA)).mode, fs.lstatSync(__dirname + path.sep + theRequireContentB).mode, fs.lstatSync(__dirname + '/' + theRequireContentB).mode, windows ? fs.lstatSync(__dirname + '/\\' + theRequireContentB).mode : '', windows ? fs.lstatSync(__dirname + '\\' + theRequireContentB).mode : '', windows ? fs.lstatSync(__dirname + '\\/' + theRequireContentB).mode : '', fs.lstatSync(firstLowerCase(path.join(__dirname, theRequireContentA))).mode, fs.lstatSync(firstLowerCase(__dirname + path.sep + theRequireContentB)) .mode, fs.lstatSync(firstLowerCase(__dirname + '/' + theRequireContentB)).mode, windows ? fs.lstatSync(firstLowerCase(__dirname + '/\\' + theRequireContentB)) .mode : '', windows ? fs.lstatSync(firstLowerCase(__dirname + '\\' + theRequireContentB)).mode : '', windows ? fs.lstatSync(firstLowerCase(__dirname + '\\/' + theRequireContentB)) .mode : '', fs.lstatSync(firstUpperCase(path.join(__dirname, theRequireContentA))).mode, fs.lstatSync(firstUpperCase(__dirname + path.sep + theRequireContentB)) .mode, fs.lstatSync(firstUpperCase(__dirname + '/' + theRequireContentB)).mode, windows ? fs.lstatSync(firstUpperCase(__dirname + '/\\' + theRequireContentB)) .mode : '', windows ? fs.lstatSync(firstUpperCase(__dirname + '\\' + theRequireContentB)).mode : '', windows ? fs.lstatSync(firstUpperCase(__dirname + '\\/' + theRequireContentB)) .mode : '', // fs.realpathSync(path.join(__dirname, theRequireContentA)).mode, fs.realpathSync(__dirname + path.sep + theRequireContentB).mode, fs.realpathSync(__dirname + '/' + theRequireContentB).mode, windows ? fs.realpathSync(__dirname + '/\\' + theRequireContentB).mode : '', windows ? fs.realpathSync(__dirname + '\\' + theRequireContentB).mode : '', windows ? fs.realpathSync(__dirname + '\\/' + theRequireContentB).mode : '', fs.realpathSync(firstLowerCase(path.join(__dirname, theRequireContentA))) .mode, fs.realpathSync(firstLowerCase(__dirname + path.sep + theRequireContentB)) .mode, fs.realpathSync(firstLowerCase(__dirname + '/' + theRequireContentB)).mode, windows ? fs.realpathSync(firstLowerCase(__dirname + '/\\' + theRequireContentB)) .mode : '', windows ? fs.realpathSync(firstLowerCase(__dirname + '\\' + theRequireContentB)) .mode : '', windows ? fs.realpathSync(firstLowerCase(__dirname + '\\/' + theRequireContentB)) .mode : '', fs.realpathSync(firstUpperCase(path.join(__dirname, theRequireContentA))) .mode, fs.realpathSync(firstUpperCase(__dirname + path.sep + theRequireContentB)) .mode, fs.realpathSync(firstUpperCase(__dirname + '/' + theRequireContentB)).mode, windows ? fs.realpathSync(firstUpperCase(__dirname + '/\\' + theRequireContentB)) .mode : '', windows ? fs.realpathSync(firstUpperCase(__dirname + '\\' + theRequireContentB)) .mode : '', windows ? fs.realpathSync(firstUpperCase(__dirname + '\\/' + theRequireContentB)) .mode : '', ].join('\n') ); ================================================ FILE: test/test-50-fs-runtime-layer/test-x2-index.js ================================================ /* eslint-disable brace-style */ /* eslint-disable complexity */ /* eslint-disable no-path-concat */ 'use strict'; var fs = require('fs'); var path = require('path'); var assert = require('assert'); var theRequireContentA = './test-z-asset-A.css'; var theRequireContentB = 'test-z-asset-B.css'; function firstLowerCase(s) { return s.slice(0, 1).toLowerCase() + s.slice(1); } function firstUpperCase(s) { return s.slice(0, 1).toUpperCase() + s.slice(1); } // /////////////////////////////////////////////////////////////////////////// fs.readFile(path.join(__dirname, theRequireContentA), function (e01, v01) { fs.readFile(__dirname + path.sep + theRequireContentB, function (e02, v02) { fs.readFile(__dirname + '/' + theRequireContentB, function (e03, v03) { fs.readFile( firstLowerCase(path.join(__dirname, theRequireContentA)), function (e04, v04) { fs.readFile( firstLowerCase(__dirname + path.sep + theRequireContentB), function (e05, v05) { fs.readFile( firstLowerCase(__dirname + '/' + theRequireContentB), function (e06, v06) { fs.readFile( firstUpperCase(path.join(__dirname, theRequireContentA)), function (e07, v07) { fs.readFile( firstUpperCase( __dirname + path.sep + theRequireContentB ), function (e08, v08) { fs.readFile( firstUpperCase( __dirname + '/' + theRequireContentB ), function (e09, v09) { // fs.readFile( path.join(__dirname, theRequireContentA), { encoding: 'utf8' }, function (e01a, v01a) { fs.readFile( __dirname + path.sep + theRequireContentB, { encoding: 'utf8' }, function (e02a, v02a) { fs.readFile( __dirname + '/' + theRequireContentB, { encoding: 'utf8' }, function (e03a, v03a) { fs.readFile( firstLowerCase( path.join( __dirname, theRequireContentA ) ), { encoding: 'utf8' }, function (e04a, v04a) { fs.readFile( firstLowerCase( __dirname + path.sep + theRequireContentB ), { encoding: 'utf8' }, function (e05a, v05a) { fs.readFile( firstLowerCase( __dirname + '/' + theRequireContentB ), { encoding: 'utf8' }, function (e06a, v06a) { fs.readFile( firstUpperCase( path.join( __dirname, theRequireContentA ) ), { encoding: 'utf8' }, function (e07a, v07a) { fs.readFile( firstUpperCase( __dirname + path.sep + theRequireContentB ), { encoding: 'utf8', }, function ( e08a, v08a ) { fs.readFile( firstUpperCase( __dirname + '/' + theRequireContentB ), { encoding: 'utf8', }, function ( e09a, v09a ) { // fs.readFile( path.join( __dirname, theRequireContentA + '-no-such' ), function ( e10, v10 ) { fs.readFile( __dirname + path.sep + theRequireContentB + '-no-such', function ( e11, v11 ) { fs.readFile( __dirname + '/' + theRequireContentB + '-no-such', function ( e12, v12 ) { fs.readFile( firstLowerCase( path.join( __dirname, theRequireContentA + '-no-such' ) ), function ( e13, v13 ) { fs.readFile( firstLowerCase( __dirname + path.sep + theRequireContentB + '-no-such' ), function ( e14, v14 ) { fs.readFile( firstLowerCase( __dirname + '/' + theRequireContentB + '-no-such' ), function ( e15, v15 ) { fs.readFile( firstUpperCase( path.join( __dirname, theRequireContentA + '-no-such' ) ), function ( e16, v16 ) { fs.readFile( firstUpperCase( __dirname + path.sep + theRequireContentB + '-no-such' ), function ( e17, v17 ) { fs.readFile( firstUpperCase( __dirname + '/' + theRequireContentB + '-no-such' ), function ( e18, v18 ) { // fs.readFile( __dirname, function ( e19, v19 ) { fs.readFile( path.dirname( __dirname ), function ( e20, v20 ) { fs.readFile( path.dirname( path.dirname( __dirname ) ), function ( e21, v21 ) { fs.readFile( firstLowerCase( __dirname ), function ( e22, v22 ) { fs.readFile( firstLowerCase( path.dirname( __dirname ) ), function ( e23, v23 ) { fs.readFile( firstLowerCase( path.dirname( path.dirname( __dirname ) ) ), function ( e24, v24 ) { fs.readFile( firstUpperCase( __dirname ), function ( e25, v25 ) { fs.readFile( firstUpperCase( path.dirname( __dirname ) ), function ( e26, v26 ) { fs.readFile( firstUpperCase( path.dirname( path.dirname( __dirname ) ) ), function ( e27, v27 ) { // fs.open( path.join( __dirname, theRequireContentA ), 'r', function ( e28, v28 ) { fs.open( __dirname + path.sep + theRequireContentB, 'r', function ( e29, v29 ) { fs.open( __dirname + '/' + theRequireContentB, 'r', function ( e30, v30 ) { fs.open( firstLowerCase( path.join( __dirname, theRequireContentA ) ), 'r', function ( e31, v31 ) { fs.open( firstLowerCase( __dirname + path.sep + theRequireContentB ), 'r', function ( e32, v32 ) { fs.open( firstLowerCase( __dirname + '/' + theRequireContentB ), 'r', function ( e33, v33 ) { fs.open( firstUpperCase( path.join( __dirname, theRequireContentA ) ), 'r', function ( e34, v34 ) { fs.open( firstUpperCase( __dirname + path.sep + theRequireContentB ), 'r', function ( e35, v35 ) { fs.open( firstUpperCase( __dirname + '/' + theRequireContentB ), 'r', function ( e36, v36 ) { // fs.open( path.join( __dirname, theRequireContentA + '-no-such' ), 'r', function ( e37, v37 ) { fs.open( __dirname + path.sep + theRequireContentB + '-no-such', 'r', function ( e38, v38 ) { fs.open( __dirname + '/' + theRequireContentB + '-no-such', 'r', function ( e39, v39 ) { fs.open( firstLowerCase( path.join( __dirname, theRequireContentA + '-no-such' ) ), 'r', function ( e40, v40 ) { fs.open( firstLowerCase( __dirname + path.sep + theRequireContentB + '-no-such' ), 'r', function ( e41, v41 ) { fs.open( firstLowerCase( __dirname + '/' + theRequireContentB + '-no-such' ), 'r', function ( e42, v42 ) { fs.open( firstUpperCase( path.join( __dirname, theRequireContentA + '-no-such' ) ), 'r', function ( e43, v43 ) { fs.open( firstUpperCase( __dirname + path.sep + theRequireContentB + '-no-such' ), 'r', function ( e44, v44 ) { fs.open( firstUpperCase( __dirname + '/' + theRequireContentB + '-no-such' ), 'r', function ( e45, v45 ) { // fs.open( __dirname, 'r', function ( e46, v46 ) { fs.open( path.dirname( __dirname ), 'r', function ( e47, v47 ) { fs.open( path.dirname( __dirname ), 'r', function ( e48, v48 ) { // not "path.dirname(path.dirname" due to denominator fs.open( firstLowerCase( __dirname ), 'r', function ( e49, v49 ) { fs.open( firstLowerCase( path.dirname( __dirname ) ), 'r', function ( e50, v50 ) { fs.open( firstLowerCase( path.dirname( __dirname ) ), 'r', function ( e51, v51 ) { // not "path.dirname(path.dirname" due to denominator fs.open( firstUpperCase( __dirname ), 'r', function ( e52, v52 ) { fs.open( firstUpperCase( path.dirname( __dirname ) ), 'r', function ( e53, v53 ) { fs.open( firstUpperCase( path.dirname( __dirname ) ), 'r', function ( e54, v54 ) { // not "path.dirname(path.dirname" due to denominator // fs.readdir( __dirname, function ( e55, v55 ) { fs.readdir( path.dirname( __dirname ), function ( e56, v56 ) { fs.readdir( path.dirname( path.dirname( __dirname ) ), function ( e57, v57 ) { fs.readdir( firstLowerCase( __dirname ), function ( e58, v58 ) { fs.readdir( firstLowerCase( path.dirname( __dirname ) ), function ( e59, v59 ) { fs.readdir( firstLowerCase( path.dirname( path.dirname( __dirname ) ) ), function ( e60, v60 ) { fs.readdir( firstUpperCase( __dirname ), function ( e61, v61 ) { fs.readdir( firstUpperCase( path.dirname( __dirname ) ), function ( e62, v62 ) { fs.readdir( firstUpperCase( path.dirname( path.dirname( __dirname ) ) ), function ( e63, v63 ) { // fs.readdir( __dirname + '-no-such', function ( e64, v64 ) { fs.readdir( path.dirname( __dirname ) + '-no-such', function ( e65, v65 ) { fs.readdir( path.dirname( path.dirname( __dirname ) ) + '-no-such', function ( e66, v66 ) { fs.readdir( firstLowerCase( __dirname + '-no-such' ), function ( e67, v67 ) { fs.readdir( firstLowerCase( path.dirname( __dirname ) + '-no-such' ), function ( e68, v68 ) { fs.readdir( firstLowerCase( path.dirname( path.dirname( __dirname ) ) + '-no-such' ), function ( e69, v69 ) { fs.readdir( firstUpperCase( __dirname + '-no-such' ), function ( e70, v70 ) { fs.readdir( firstUpperCase( path.dirname( __dirname ) + '-no-such' ), function ( e71, v71 ) { fs.readdir( firstUpperCase( path.dirname( path.dirname( __dirname ) ) + '-no-such' ), function ( e72, v72 ) { // fs.readdir( path.join( __dirname, theRequireContentA ), function ( e73, v73 ) { fs.readdir( __dirname + path.sep + theRequireContentB, function ( e74, v74 ) { fs.readdir( __dirname + '/' + theRequireContentB, function ( e75, v75 ) { fs.readdir( firstLowerCase( path.join( __dirname, theRequireContentA ) ), function ( e76, v76 ) { fs.readdir( firstLowerCase( __dirname + path.sep + theRequireContentB ), function ( e77, v77 ) { fs.readdir( firstLowerCase( __dirname + '/' + theRequireContentB ), function ( e78, v78 ) { fs.readdir( firstUpperCase( path.join( __dirname, theRequireContentA ) ), function ( e79, v79 ) { fs.readdir( firstUpperCase( __dirname + path.sep + theRequireContentB ), function ( e80, v80 ) { fs.readdir( firstUpperCase( __dirname + '/' + theRequireContentB ), function ( e81, v81 ) { // fs.fstat( v28, function ( e136, v136 ) { fs.fstat( v29, function ( e137, v137 ) { fs.fstat( v30, function ( e138, v138 ) { fs.fstat( v46, function ( e139, v139 ) { fs.fstat( v47, function ( e140, v140 ) { fs.fstat( v48, function ( e141, v141 ) { fs.fstat( v49, function ( e142, v142 ) { fs.fstat( v50, function ( e143, v143 ) { fs.fstat( v51, function ( e144, v144 ) { console.log( [ '******************************************************', '******************************************************', '******************************************************', 'readFile', assert( e01 === null ), e01 === null, v01.length, e02 === null, v02.length, e03 === null, v03.length, e04 === null, v04.length, e05 === null, v05.length, e06 === null, v06.length, e07 === null, v07.length, e08 === null, v08.length, e09 === null, v09.length, '******************************************************', '******************************************************', '******************************************************', 'readFile', assert( e01a === null ), e01a === null, v01a.length, e02a === null, v02a.length, e03a === null, v03a.length, e04a === null, v04a.length, e05a === null, v05a.length, e06a === null, v06a.length, e07a === null, v07a.length, e08a === null, v08a.length, e09a === null, v09a.length, '******************************************************', '******************************************************', '******************************************************', 'readFile-no-such', assert( e10.errno === -4058 || e10.errno === -2 ), e10.errno, e10.code, v10 === undefined, e11.errno, e11.code, v11 === undefined, e12.errno, e12.code, v12 === undefined, e13.errno, e13.code, v13 === undefined, e14.errno, e14.code, v14 === undefined, e15.errno, e15.code, v15 === undefined, e16.errno, e16.code, v16 === undefined, e17.errno, e17.code, v17 === undefined, e18.errno, e18.code, v18 === undefined, '******************************************************', '******************************************************', '******************************************************', 'readFile-directory', assert( !e19 || e19.errno === -4068 || e19.errno === -21 ), !e19 || e19.errno, !e19 || e19.code, v19 === undefined, !e20 || e20.errno, !e20 || e20.code, v20 === undefined, !e21 || e21.errno, !e21 || e21.code, v21 === undefined, !e22 || e22.errno, !e22 || e22.code, v22 === undefined, !e23 || e23.errno, !e23 || e23.code, v23 === undefined, !e24 || e24.errno, !e24 || e24.code, v24 === undefined, !e25 || e25.errno, !e25 || e25.code, v25 === undefined, !e26 || e26.errno, !e26 || e26.code, v26 === undefined, !e27 || e27.errno, !e27 || e27.code, v27 === undefined, '******************************************************', '******************************************************', '******************************************************', 'open', assert( e28 === null ), e28 === null, typeof v28, e29 === null, typeof v29, e30 === null, typeof v30, e31 === null, typeof v31, e32 === null, typeof v32, e33 === null, typeof v33, e34 === null, typeof v34, e35 === null, typeof v35, e36 === null, typeof v36, '******************************************************', '******************************************************', '******************************************************', 'open-no-such', assert( e37.errno === -4058 || e37.errno === -2 ), e37.errno, e37.code, v37 === undefined, e38.errno, e38.code, v38 === undefined, e39.errno, e39.code, v39 === undefined, e40.errno, e40.code, v40 === undefined, e41.errno, e41.code, v41 === undefined, e42.errno, e42.code, v42 === undefined, e43.errno, e43.code, v43 === undefined, e44.errno, e44.code, v44 === undefined, e45.errno, e45.code, v45 === undefined, '******************************************************', '******************************************************', '******************************************************', 'open-directory', assert( e46 === null ), e46 === null, typeof v46, e47 === null, typeof v47, e48 === null, typeof v48, e49 === null, typeof v49, e50 === null, typeof v50, e51 === null, typeof v51, e52 === null, typeof v52, e53 === null, typeof v53, e54 === null, typeof v54, '******************************************************', '******************************************************', '******************************************************', 'readdir', assert( e55 === null ), assert( v55.length > 0 ), e55 === null, v55.length > 0, e56 === null, v56.length > 0, e57 === null, v57.length > 0, e58 === null, v58.length > 0, e59 === null, v59.length > 0, e60 === null, v60.length > 0, e61 === null, v61.length > 0, e62 === null, v62.length > 0, e63 === null, v63.length > 0, '******************************************************', '******************************************************', '******************************************************', 'readdir-no-such', assert( e64.errno === -4058 || e64.errno === -2 ), e64.errno, e64.code, v64 === undefined, e65.errno, e65.code, v65 === undefined, e66.errno, e66.code, v66 === undefined, e67.errno, e67.code, v67 === undefined, e68.errno, e68.code, v68 === undefined, e69.errno, e69.code, v69 === undefined, e70.errno, e70.code, v70 === undefined, e71.errno, e71.code, v71 === undefined, e72.errno, e72.code, v72 === undefined, '******************************************************', '******************************************************', '******************************************************', 'readdir-file', assert( e73.errno === -4052 || e73.errno === -20 ), e73.errno, e73.code, v73 === undefined, e74.errno, e74.code, v74 === undefined, e75.errno, e75.code, v75 === undefined, e76.errno, e76.code, v76 === undefined, e77.errno, e77.code, v77 === undefined, e78.errno, e78.code, v78 === undefined, e79.errno, e79.code, v79 === undefined, e80.errno, e80.code, v80 === undefined, e81.errno, e81.code, v81 === undefined, '******************************************************', '******************************************************', '******************************************************', 'fstat', assert( e136 === null ), e136 === null, v136.mode, v136.isFile(), v136.isDirectory(), e137 === null, v137.mode, v137.isFile(), v137.isDirectory(), e138 === null, v138.mode, v138.isFile(), v138.isDirectory(), e139 === null, v139.mode, v139.isFile(), v139.isDirectory(), e140 === null, v140.mode, v140.isFile(), v140.isDirectory(), e141 === null, v141.mode, v141.isFile(), v141.isDirectory(), e142 === null, v142.mode, v142.isFile(), v142.isDirectory(), e143 === null, v143.mode, v143.isFile(), v143.isDirectory(), e144 === null, v144.mode, v144.isFile(), v144.isDirectory(), '******************************************************', '******************************************************', '******************************************************', ].join( '\n' ) ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); }); }); }); ================================================ FILE: test/test-50-fs-runtime-layer/test-x3-index.js ================================================ /* eslint-disable brace-style */ /* eslint-disable no-path-concat */ 'use strict'; var fs = require('fs'); var path = require('path'); var assert = require('assert'); var theRequireContentA = './test-z-asset-A.css'; var theRequireContentB = 'test-z-asset-B.css'; function firstLowerCase(s) { return s.slice(0, 1).toLowerCase() + s.slice(1); } function firstUpperCase(s) { return s.slice(0, 1).toUpperCase() + s.slice(1); } // /////////////////////////////////////////////////////////////////////////// fs.exists(path.join(__dirname, theRequireContentA), function (e82, v82) { fs.exists(__dirname + path.sep + theRequireContentB, function (e83, v83) { fs.exists(__dirname + '/' + theRequireContentB, function (e84, v84) { fs.exists( firstLowerCase(path.join(__dirname, theRequireContentA)), function (e85, v85) { fs.exists( firstLowerCase(__dirname + path.sep + theRequireContentB), function (e86, v86) { fs.exists( firstLowerCase(__dirname + '/' + theRequireContentB), function (e87, v87) { fs.exists( firstUpperCase(path.join(__dirname, theRequireContentA)), function (e88, v88) { fs.exists( firstUpperCase( __dirname + path.sep + theRequireContentB ), function (e89, v89) { fs.exists( firstUpperCase( __dirname + '/' + theRequireContentB ), function (e90, v90) { // fs.exists( path.join( __dirname, theRequireContentA + '-no-such' ), function (e91, v91) { fs.exists( __dirname + path.sep + theRequireContentB + '-no-such', function (e92, v92) { fs.exists( __dirname + '/' + theRequireContentB + '-no-such', function (e93, v93) { fs.exists( firstLowerCase( path.join( __dirname, theRequireContentA + '-no-such' ) ), function (e94, v94) { fs.exists( firstLowerCase( __dirname + path.sep + theRequireContentB + '-no-such' ), function (e95, v95) { fs.exists( firstLowerCase( __dirname + '/' + theRequireContentB + '-no-such' ), function (e96, v96) { fs.exists( firstUpperCase( path.join( __dirname, theRequireContentA + '-no-such' ) ), function (e97, v97) { fs.exists( firstUpperCase( __dirname + path.sep + theRequireContentB + '-no-such' ), function ( e98, v98 ) { fs.exists( firstUpperCase( __dirname + '/' + theRequireContentB + '-no-such' ), function ( e99, v99 ) { // fs.access( path.join( __dirname, theRequireContentA ), function ( e100, v100 ) { fs.access( __dirname + path.sep + theRequireContentB, function ( e101, v101 ) { fs.access( __dirname + '/' + theRequireContentB, function ( e102, v102 ) { fs.access( firstLowerCase( path.join( __dirname, theRequireContentA ) ), function ( e103, v103 ) { fs.access( firstLowerCase( __dirname + path.sep + theRequireContentB ), function ( e104, v104 ) { fs.access( firstLowerCase( __dirname + '/' + theRequireContentB ), function ( e105, v105 ) { fs.access( firstUpperCase( path.join( __dirname, theRequireContentA ) ), function ( e106, v106 ) { fs.access( firstUpperCase( __dirname + path.sep + theRequireContentB ), function ( e107, v107 ) { fs.access( firstUpperCase( __dirname + '/' + theRequireContentB ), function ( e108, v108 ) { // fs.access( path.join( __dirname, theRequireContentA + '-no-such' ), function ( e109, v109 ) { fs.access( __dirname + path.sep + theRequireContentB + '-no-such', function ( e110, v110 ) { fs.access( __dirname + '/' + theRequireContentB + '-no-such', function ( e111, v111 ) { fs.access( firstLowerCase( path.join( __dirname, theRequireContentA + '-no-such' ) ), function ( e112, v112 ) { fs.access( firstLowerCase( __dirname + path.sep + theRequireContentB + '-no-such' ), function ( e113, v113 ) { fs.access( firstLowerCase( __dirname + '/' + theRequireContentB + '-no-such' ), function ( e114, v114 ) { fs.access( firstUpperCase( path.join( __dirname, theRequireContentA + '-no-such' ) ), function ( e115, v115 ) { fs.access( firstUpperCase( __dirname + path.sep + theRequireContentB + '-no-such' ), function ( e116, v116 ) { fs.access( firstUpperCase( __dirname + '/' + theRequireContentB + '-no-such' ), function ( e117, v117 ) { // fs.stat( path.join( __dirname, theRequireContentA ), function ( e118, v118 ) { fs.stat( __dirname + path.sep + theRequireContentB, function ( e119, v119 ) { fs.stat( __dirname + '/' + theRequireContentB, function ( e120, v120 ) { fs.stat( firstLowerCase( path.join( __dirname, theRequireContentA ) ), function ( e121, v121 ) { fs.stat( firstLowerCase( __dirname + path.sep + theRequireContentB ), function ( e122, v122 ) { fs.stat( firstLowerCase( __dirname + '/' + theRequireContentB ), function ( e123, v123 ) { fs.stat( firstUpperCase( path.join( __dirname, theRequireContentA ) ), function ( e124, v124 ) { fs.stat( firstUpperCase( __dirname + path.sep + theRequireContentB ), function ( e125, v125 ) { fs.stat( firstUpperCase( __dirname + '/' + theRequireContentB ), function ( e126, v126 ) { // fs.lstat( path.join( __dirname, theRequireContentA ), function ( e127, v127 ) { fs.lstat( __dirname + path.sep + theRequireContentB, function ( e128, v128 ) { fs.lstat( __dirname + '/' + theRequireContentB, function ( e129, v129 ) { fs.lstat( firstLowerCase( path.join( __dirname, theRequireContentA ) ), function ( e130, v130 ) { fs.lstat( firstLowerCase( __dirname + path.sep + theRequireContentB ), function ( e131, v131 ) { fs.lstat( firstLowerCase( __dirname + '/' + theRequireContentB ), function ( e132, v132 ) { fs.lstat( firstUpperCase( path.join( __dirname, theRequireContentA ) ), function ( e133, v133 ) { fs.lstat( firstUpperCase( __dirname + path.sep + theRequireContentB ), function ( e134, v134 ) { fs.lstat( firstUpperCase( __dirname + '/' + theRequireContentB ), function ( e135, v135 ) { // fs.realpath( path.join( __dirname, theRequireContentA ), function ( e145, v145 ) { fs.realpath( __dirname + path.sep + theRequireContentB, function ( e146, v146 ) { fs.realpath( __dirname + '/' + theRequireContentB, function ( e147, v147 ) { fs.realpath( firstLowerCase( path.join( __dirname, theRequireContentA ) ), function ( e148, v148 ) { fs.realpath( firstLowerCase( __dirname + path.sep + theRequireContentB ), function ( e149, v149 ) { fs.realpath( firstLowerCase( __dirname + '/' + theRequireContentB ), function ( e150, v150 ) { fs.realpath( firstUpperCase( path.join( __dirname, theRequireContentA ) ), function ( e151, v151 ) { fs.realpath( firstUpperCase( __dirname + path.sep + theRequireContentB ), function ( e152, v152 ) { fs.realpath( firstUpperCase( __dirname + '/' + theRequireContentB ), function ( e153, v153 ) { console.log( [ '******************************************************', '******************************************************', '******************************************************', 'exists', assert( v82 === undefined ), e82, v82 === undefined, e83, v83 === undefined, e84, v84 === undefined, e85, v85 === undefined, e86, v86 === undefined, e87, v87 === undefined, e88, v88 === undefined, e89, v89 === undefined, e90, v90 === undefined, '******************************************************', '******************************************************', '******************************************************', 'exists-no-such', assert( v91 === undefined ), e91, v91 === undefined, e92, v92 === undefined, e93, v93 === undefined, e94, v94 === undefined, e95, v95 === undefined, e96, v96 === undefined, e97, v97 === undefined, e98, v98 === undefined, e99, v99 === undefined, '******************************************************', '******************************************************', '******************************************************', 'access', assert( v100 === undefined || v100 === 0 ), e100 === null, v100 === undefined || v100 === 0, // odd behaviour in 0.12.14 e101 === null, v101 === undefined || v101 === 0, // callback args are (null, 0). wtf 0? e102 === null, v102 === undefined || v102 === 0, e103 === null, v103 === undefined || v103 === 0, e104 === null, v104 === undefined || v104 === 0, e105 === null, v105 === undefined || v105 === 0, e106 === null, v106 === undefined || v106 === 0, e107 === null, v107 === undefined || v107 === 0, e108 === null, v108 === undefined || v108 === 0, '******************************************************', '******************************************************', '******************************************************', 'access-no-such', assert( v109 === undefined ), e109.errno, e109.code, v109 === undefined, e110.errno, e110.code, v110 === undefined, e111.errno, e111.code, v111 === undefined, e112.errno, e112.code, v112 === undefined, e113.errno, e113.code, v113 === undefined, e114.errno, e114.code, v114 === undefined, e115.errno, e115.code, v115 === undefined, e116.errno, e116.code, v116 === undefined, e117.errno, e117.code, v117 === undefined, '******************************************************', '******************************************************', '******************************************************', 'stat', assert( e118 === null ), e118 === null, v118.mode, v118.isFile(), v118.isDirectory(), e119 === null, v119.mode, v119.isFile(), v119.isDirectory(), e120 === null, v120.mode, v120.isFile(), v120.isDirectory(), e121 === null, v121.mode, v121.isFile(), v121.isDirectory(), e122 === null, v122.mode, v122.isFile(), v122.isDirectory(), e123 === null, v123.mode, v123.isFile(), v123.isDirectory(), e124 === null, v124.mode, v124.isFile(), v124.isDirectory(), e125 === null, v125.mode, v125.isFile(), v125.isDirectory(), e126 === null, v126.mode, v126.isFile(), v126.isDirectory(), '******************************************************', '******************************************************', '******************************************************', 'lstat', assert( e127 === null ), e127 === null, v127.mode, v127.isFile(), v127.isDirectory(), e128 === null, v128.mode, v128.isFile(), v128.isDirectory(), e129 === null, v129.mode, v129.isFile(), v129.isDirectory(), e130 === null, v130.mode, v130.isFile(), v130.isDirectory(), e131 === null, v131.mode, v131.isFile(), v131.isDirectory(), e132 === null, v132.mode, v132.isFile(), v132.isDirectory(), e133 === null, v133.mode, v133.isFile(), v133.isDirectory(), e134 === null, v134.mode, v134.isFile(), v134.isDirectory(), e135 === null, v135.mode, v135.isFile(), v135.isDirectory(), '******************************************************', '******************************************************', '******************************************************', 'realpath', assert( e145 === null ), e145 === null, path.basename( v145 ), path.basename( path.dirname( v145 ) ), e146 === null, path.basename( v146 ), path.basename( path.dirname( v146 ) ), e147 === null, path.basename( v147 ), path.basename( path.dirname( v147 ) ), e148 === null, path.basename( v148 ), path.basename( path.dirname( v148 ) ), e149 === null, path.basename( v149 ), path.basename( path.dirname( v149 ) ), e150 === null, path.basename( v150 ), path.basename( path.dirname( v150 ) ), e151 === null, path.basename( v151 ), path.basename( path.dirname( v151 ) ), e152 === null, path.basename( v152 ), path.basename( path.dirname( v152 ) ), e153 === null, path.basename( v153 ), path.basename( path.dirname( v153 ) ), '******************************************************', '******************************************************', '******************************************************', ].join( '\n' ) ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); } ); }); }); }); ================================================ FILE: test/test-50-fs-runtime-layer/test-z-asset-A.css ================================================ .ui-button, .ui-button:link, .ui-button:visited, .ui-button:hover, .ui-button:active { text-decoration: none; } /* to make room for the icon, a width needs to be set here */ .ui-button-icon-only { width: 2.2em; } /* button elements seem to need a little more width */ button.ui-button-icon-only { width: 2.4em; } .ui-button-icons-only { width: 3.4em; } button.ui-button-icons-only { width: 3.7em; } /* button text element */ .ui-button .ui-button-text { display: block; line-height: normal; } .ui-button-text-only .ui-button-text { padding: 0.4em 1em; } .ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: 0.4em; text-indent: -9999999px; } .ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: 0.4em 1em 0.4em 2.1em; } .ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: 0.4em 2.1em 0.4em 1em; } .ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; } ================================================ FILE: test/test-50-fs-runtime-layer/test-z-asset-B.css ================================================ .header { background: #444; border: solid; padding: 10px; border-radius: 10px 5px 10px 5px; color: #b4b472; } #main li { color: green; margin: 10px; padding: 10px; font-size: 18px; } ================================================ FILE: test/test-50-fs-runtime-layer-2/main.js ================================================ #!/usr/bin/env node /* eslint-disable no-multi-spaces */ 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; // see readFromSnapshot "NODE_VERSION_MAJOR" function bitty(version) { return ( (4 * /^(node|v)?8/.test(version)) | (8 * /^(node|v)?10/.test(version)) | (16 * /^(node|v)?12/.test(version)) | (32 * /^(node|v)?14/.test(version)) | (64 * /^(node|v)?16/.test(version)) | (128 * /^(node|v)?18/.test(version)) ); } const version1 = process.version; const version2 = target; if (bitty(version1) === bitty(version2)) { let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); left = left.split('\n'); right = right.split('\n'); // right may have less lines, premature exit, // less trusted, so using left.length here for (let i = 0; i < left.length; i += 1) { if (/is out of range/.test(left[i]) && /is out of range/.test(right[i])) { left[i] = left[i].replace(/ It must be .*\. /, ' '); right[i] = right[i].replace(/ It must be .*\. /, ' '); } assert.strictEqual(left[i], right[i]); } utils.vacuum.sync(path.dirname(output)); } ================================================ FILE: test/test-50-fs-runtime-layer-2/test-x-index.js ================================================ /* eslint-disable max-statements-per-line */ 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); const theFile = path.join(__dirname, 'test-z-asset.css'); const theDirectory = __dirname; function dumpError(error) { let s = error.message; if (s === 'Bad argument') { s = 'fd must be a file descriptor'; } else if (s === 'EBADF, bad file descriptor' && error.syscall === 'fstat') { s = 'EBADF: bad file descriptor, fstat'; } else if (s === 'EBADF, bad file descriptor') { s = 'EBADF: bad file descriptor'; } else if (s === 'EBADF: bad file descriptor, close') { s = 'EBADF: bad file descriptor'; } else if (s === 'EISDIR, illegal operation on a directory') { s = 'EISDIR: illegal operation on a directory, read'; } console.log(s); } test01(); function test01() { console.log('<<< test01 >>>'); fs.stat(theFile, function (error, stats) { console.log('fs.stat.error === null', error === null); console.log('stats.size', stats.size); fs.open(theFile, 'r', function (error2, fd) { console.log('fs.open.error2 === null', error2 === null); console.log('typeof fd', typeof fd); fs.fstat(fd, function (error3, fstats) { console.log('fs.fstat.error3 === null', error3 === null); console.log('fstats.size', fstats.size); const buffer = Buffer.alloc((stats.size / 2) | 0); fs.read( fd, buffer, 0, buffer.length, null, function (error4, bytesRead, buffer2) { console.log('fs.read.error4 === null', error4 === null); console.log('buffer === buffer2', buffer === buffer2); // should be same instances const data2 = buffer2.toString('utf8', 0, buffer2.length); console.log('data2', data2); fs.close(fd, function (error5, wtf) { console.log('fs.close.error5 === null', error5 === null); console.log('typeof wtf', typeof wtf); fs.readFile(theFile, function (error6, buffer3) { console.log('fs.readFile.error6 === null', error6 === null); const data3 = buffer3.toString('utf8', 0, buffer3.length); console.log('data3', data3); const buffer4 = buffer3; fs.writeFile(theFile, buffer4, function (error7, wtf2) { if (process.pkg) { assert.strictEqual(typeof error7, 'object'); // TODO maybe code=EACCESS? } else { assert.strictEqual(error7, null); } console.log('typeof wtf2', typeof wtf2); fs.readdir(theDirectory, function (error8, list) { console.log('fs.readdir.error8 === null', error8 === null); console.log('Array.isArray(list)', Array.isArray(list)); fs.exists(theFile, function (value, wtf3) { console.log('value', value); console.log('typeof wtf3', typeof wtf3); fs.exists(theDirectory, function (value2, wtf4) { console.log('value2', value2); console.log('typeof wtf4', typeof wtf4); fs.realpath(theFile, function (error9, real) { console.log( 'fs.realpath.error9 === null', error9 === null ); console.log('typeof real', typeof real); test01e(fd); }); console.log('after fs.realpath'); }); console.log('after fs.exists(theDirectory)'); }); console.log('after fs.exists(theFile)'); }); console.log('after fs.readdir'); }); console.log('after fs.writeFile'); }); console.log('after fs.readFile'); }); console.log('after fs.close'); } ); console.log('after fs.read'); }); console.log('after fs.fstat'); }); console.log('after fs.open'); }); console.log('after fs.stat'); } function test01e(badFd) { console.log('<<< test01e >>>'); fs.stat('notExists', function (error) { console.log('fs.stat.error.code', error.code); fs.open('notExists', 'r', function (error2, fd) { console.log('fs.open.error2.code', error2.code); fd = badFd; fs.fstat(fd, function (error3) { console.log('fs.fstat.error3.code', error3.code); const buffer = Buffer.alloc(1024); fs.read( fd, buffer, 0, buffer.length, null, function (error4, bytesRead, buffer2) { console.log('fs.read.error4.code', error4.code); console.log('typeof bytesRead', typeof bytesRead); console.log('typeof buffer2', typeof buffer2); fs.close(fd, function (error5, wtf) { console.log('fs.close.error5.code', error5.code); console.log('typeof wtf', typeof wtf); fs.readFile(theDirectory, function (error6, buffer3) { console.log('fs.readFile.error6.code', error6.code); console.log('typeof buffer3', typeof buffer3); fs.readFile('notExists', function (error7, buffer4) { console.log('fs.readFile.error7.code', error7.code); console.log('typeof buffer4', typeof buffer4); const buffer5 = Buffer.alloc(1024); fs.writeFile( theFile + '/canNotWrite', buffer5, function (error8, wtf2) { assert( error8.code === 'ENOENT' || error8.code === 'ENOTDIR' ); console.log('typeof wtf2', typeof wtf2); fs.readdir(theFile, function (error9, list) { console.log('fs.readdir.error9.code', error9.code); console.log('typeof list', typeof list); fs.readdir('notExists', function (error10, list2) { console.log('fs.readdir.error10.code', error10.code); console.log('typeof list2', typeof list2); fs.exists('notExists', function (value, wtf3) { console.log('value', value); console.log('typeof wtf3', typeof wtf3); fs.realpath('notExists', function (error11, real) { console.log( 'fs.realpath.error11.code', error11.code ); console.log('typeof real', typeof real); test02(); }); console.log('after fs.realpath'); }); console.log('after fs.exists'); }); console.log('after fs.readdir(notExists)'); }); console.log('after fs.readdir(theFile)'); } ); console.log('after fs.writeFile'); }); console.log('after fs.readFile(notExists)'); }); console.log('after fs.readFile(theDirectory)'); }); console.log('after fs.close'); } ); console.log('after fs.read'); }); console.log('after fs.fstat'); }); console.log('after fs.open'); }); console.log('after fs.stat'); } function test02() { console.log('<<< test02 >>>'); const stats = fs.statSync(theFile); console.log('stats.size', stats.size); const fd = fs.openSync(theFile, 'r'); const fstats = fs.fstatSync(fd); console.log('fstats.size', fstats.size); const buffer = Buffer.alloc(stats.size); const bytesRead = fs.readSync(fd, buffer, 0, buffer.length); console.log('bytesRead', bytesRead); const data = buffer.toString('utf8', 0, buffer.length); console.log('data', data); fs.closeSync(fd); test03(); } function test03() { console.log('<<< test03 >>>'); const stats = fs.statSync(theFile); console.log('stats.size', stats.size); const fd = fs.openSync(theFile, 'r'); const fstats = fs.fstatSync(fd); console.log('fstats.size', fstats.size); const buffer = Buffer.alloc(6); let bytesRead = fs.readSync(fd, buffer, 0, 6); console.log('bytesRead_a', bytesRead, 'buffer', buffer[0], buffer[1]); bytesRead = fs.readSync(fd, buffer, 0, 6); console.log('bytesRead_b', bytesRead, 'buffer', buffer[0], buffer[1]); bytesRead = fs.readSync(fd, buffer, 1, 5); console.log('bytesRead_c', bytesRead, 'buffer', buffer[1], buffer[2]); try { bytesRead = fs.readSync(fd, buffer, 1, 6); } catch (error) { dumpError(error); } console.log('bytesRead_d', bytesRead, 'buffer', buffer[1], buffer[2]); bytesRead = fs.readSync(fd, buffer, 5, 1); console.log('bytesRead_e', bytesRead, 'buffer', buffer[4], buffer[5]); try { bytesRead = fs.readSync(fd, buffer, 6, 0); } catch (error) { dumpError(error); } console.log('bytesRead_f', bytesRead, 'buffer', buffer[4], buffer[5]); try { bytesRead = fs.readSync(fd, buffer, -1, 5); } catch (error) { dumpError(error); } console.log('bytesRead_g', bytesRead, 'buffer', buffer[4], buffer[5]); try { bytesRead = fs.readSync(fd, buffer, -1, 9); } catch (error) { dumpError(error); } console.log('bytesRead_h', bytesRead, 'buffer', buffer[4], buffer[5]); bytesRead = fs.readSync(fd, buffer, 0, 6); console.log('bytesRead_i', bytesRead, 'buffer', buffer[0], buffer[1]); bytesRead = fs.readSync(fd, buffer, 0, 6); console.log('bytesRead_j', bytesRead, 'buffer', buffer[0], buffer[1]); bytesRead = fs.readSync(fd, buffer, 0, 6); console.log('bytesRead_k', bytesRead, 'buffer', buffer[0], buffer[1]); bytesRead = fs.readSync(fd, buffer, 0, 6); console.log('bytesRead_l', bytesRead, 'buffer', buffer[0], buffer[1]); bytesRead = fs.readSync(fd, buffer, 0, 6); console.log('bytesRead_m', bytesRead, 'buffer', buffer[0], buffer[1]); bytesRead = fs.readSync(fd, buffer, 0, 6, 20); console.log('bytesRead_n', bytesRead, 'buffer', buffer[0], buffer[1]); bytesRead = fs.readSync(fd, buffer, 0, 6, 80); console.log('bytesRead_o', bytesRead, 'buffer', buffer[0], buffer[1]); // this does not work properly. TODO some rework of readFromSnapshot is needed // try { bytesRead = fs.readSync(fd, buffer, 424242, 1); } catch (error) { dumpError(error); } // console.log('bytesRead_p', bytesRead, 'buffer', buffer[0], buffer[1]); fs.closeSync(fd); test04(); } function test04() { const stats = fs.statSync(theDirectory); console.log(stats.mode); const fd = fs.openSync(theDirectory, 'r'); const fstats = fs.fstatSync(fd); console.log(fstats.mode); const buffer = Buffer.from([12, 34, 56, 78]); let bytesRead; try { bytesRead = fs.readSync(fd, buffer, 0, 6); } catch (error) { dumpError(error); } console.log(bytesRead, buffer[0], buffer[1]); try { bytesRead = fs.readSync(fd, buffer, 6, 0); } catch (error) { dumpError(error); } console.log(bytesRead, buffer[0], buffer[1]); try { bytesRead = fs.readSync(fd, buffer, -1, 3); } catch (error) { dumpError(error); } console.log(bytesRead, buffer[0], buffer[1]); try { bytesRead = fs.readSync(fd, buffer, 0, 4); } catch (error) { dumpError(error); } console.log(bytesRead, buffer[0], buffer[1]); fs.closeSync(fd); test05(); } function test05() { const fd = 'incorrect fd as string'; const buffer = Buffer.from([12, 34, 56, 78]); let bytesRead; try { bytesRead = fs.readSync(fd, buffer, 0, 6); } catch (error) { dumpError(error); } console.log(bytesRead, buffer[0], buffer[1]); try { console.log(fs.fstatSync(fd)); } catch (error) { dumpError(error); } console.log(bytesRead, buffer[0], buffer[1]); try { fs.closeSync(fd); } catch (error) { dumpError(error); } test06(); } function test06() { const fd = 7890; const buffer = Buffer.from([12, 34, 56, 78]); let bytesRead; try { bytesRead = fs.readSync(fd, buffer, 0, 6); } catch (error) { dumpError(error); } console.log(bytesRead, buffer[0], buffer[1]); try { console.log(fs.fstatSync(fd)); } catch (error) { dumpError(error); } console.log(bytesRead, buffer[0], buffer[1]); try { fs.closeSync(fd); console.log('EBADF: bad file descriptor'); } catch (error) { dumpError(error); } test07(); } function test07() { console.log('before createReadStream'); const rs = fs.createReadStream(theFile); console.log('after createReadStream'); rs.on('open', function () { console.log('open'); }); rs.on('readable', function () { console.log('before read'); let r = rs.read(); console.log('after read'); if (!r) { r = 'null'; } else if (r.length >= 2) { console.log('length:', r.length); r = r[0].toString() + ', ' + r[1].toString(); } console.log('readable:', r); }); rs.on('end', function () { console.log('end'); }); } ================================================ FILE: test/test-50-fs-runtime-layer-2/test-z-asset.css ================================================ .header { background: #444; } ================================================ FILE: test/test-50-fs-runtime-layer-3/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let right; utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual( right, 'true\n' + 'false\n' + 'Cannot write to packaged file\n' + 'true\n' + 'closed\n' + 'false\n' + 'Cannot write to packaged file\n' + 'Cannot write to packaged file\n' + 'undefined\n' + 'Cannot write to packaged file\n' + 'undefined\n' ); utils.vacuum.sync(output); ================================================ FILE: test/test-50-fs-runtime-layer-3/test-x-index.js ================================================ /* eslint-disable no-buffer-constructor */ /* eslint-disable max-statements-per-line */ 'use strict'; var fs = require('fs'); var path = require('path'); var theFile = path.join(__dirname, 'test-z-asset.css'); test01(); function test01() { fs.open(theFile, 'w+', function (error, fd) { console.log(error === null); var buffer = Buffer.from('FOO'); fs.write(fd, buffer, 0, buffer.length, null, function (error2) { console.log(error2 === null); if (error2) console.log(error2.message); fs.close(fd, function (error3) { console.log(error3 === null); console.log('closed'); fs.writeFile(theFile, 'BAR BAZ', function (error4) { console.log(error4 === null); if (error4) console.log(error4.message); test02(); }); }); }); }); } function test02() { var fd = fs.openSync(theFile, 'w+'); var buffer = Buffer.from('QUX BARABAZ'); var bytesWritten; try { bytesWritten = fs.writeSync(fd, buffer, 0, buffer.length); } catch (error) { console.log(error.message); } console.log(bytesWritten); fs.closeSync(fd); try { bytesWritten = fs.writeFileSync(theFile, 'GARAQUX'); } catch (error) { console.log(error.message); } console.log(bytesWritten); } ================================================ FILE: test/test-50-fs-runtime-layer-3/test-z-asset.css ================================================ .header { background: #444; } ================================================ FILE: test/test-50-global-object/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', ['test-x-index.js']); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-global-object/package.json ================================================ { "bin": "test-x-index.js", "pkg": { "scripts": "test-y-*" } } ================================================ FILE: test/test-50-global-object/test-x-index.js ================================================ /* eslint-disable no-useless-concat */ 'use strict'; var theA = './test-y-resolve-A.js'; var theB = './test-y-' + 'resolve-B.js'; require(theA).toString(); require(theB).toString(); ================================================ FILE: test/test-50-global-object/test-y-resolve-A.js ================================================ 'use strict'; global.x = 42; console.log(x); ================================================ FILE: test/test-50-global-object/test-y-resolve-B.js ================================================ 'use strict'; global.y = 84; console.log(y); ================================================ FILE: test/test-50-inspect/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; utils.pkg.sync(['--target', target, '--output', output, input]); utils.spawn.sync('./' + path.basename(output), ['--inspect'], { cwd: path.dirname(output), env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS' }, stdio: 'pipe', expect: 9, }); utils.vacuum.sync(output); ================================================ FILE: test/test-50-inspect/test-x-index.js ================================================ 'use strict'; setTimeout(function () { console.log('ok'); }, 3000); ================================================ FILE: test/test-50-invalid/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const standard = 'stdout'; let right; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync(['--target', target, '--output', 'no-output', '12345'], { stdio: inspect, expect: 2, }); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); assert(right.indexOf('Error!') >= 0); assert(right.indexOf('does not exist') >= 0); assert(right.indexOf('12345') >= 0); ================================================ FILE: test/test-50-invalid-package-json/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const standard = 'stdout'; let right; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync(['--target', target, '--output', 'no-output', '.'], { stdio: inspect, expect: 2, }); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); assert(right.indexOf('Error!') >= 0); assert(right.indexOf('does not exist') >= 0); assert(right.indexOf('package.json') >= 0); ================================================ FILE: test/test-50-invalid-package-json-2/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const path = require('path'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; const standard = 'stdout'; let right; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync( ['--target', target, '--output', output, input], inspect ); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); assert(right.indexOf('Warning') >= 0); assert(right.indexOf("Entry 'main' not found") >= 0); assert(right.indexOf('crusader' + path.sep + 'package.json') >= 0); utils.vacuum.sync(output); ================================================ FILE: test/test-50-invalid-package-json-2/test-x-index.js ================================================ 'use strict'; require('crusader'); ================================================ FILE: test/test-50-invalid-package-json-bin/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const standard = 'stdout'; let right; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync(['--target', target, '--output', 'no-output', '.'], { stdio: inspect, expect: 2, }); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); assert(right.indexOf('Error!') >= 0); assert(right.indexOf("Property 'bin' does not exist") >= 0); assert(right.indexOf('package.json') >= 0); ================================================ FILE: test/test-50-invalid-package-json-bin/package.json ================================================ { "name": "busboy" } ================================================ FILE: test/test-50-invalid-package-json-bin-2/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const standard = 'stdout'; let right; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync(['--target', target, '--output', 'no-output', '.'], { stdio: inspect, expect: 2, }); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); assert(right.indexOf('Error!') >= 0); assert(right.indexOf('does not exist') >= 0); assert(right.indexOf('package.json') >= 0); ================================================ FILE: test/test-50-invalid-package-json-bin-2/package.json ================================================ { "name": "busboy", "bin": "bin.js" } ================================================ FILE: test/test-50-invalid-unknown-token/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const standard = 'stdout'; let right; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync( ['--target', 'node7-x6', '--output', 'no-output', 'test-x-index.js'], { stdio: inspect, expect: 2 } ); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); assert(right.indexOf('Error!') >= 0); assert(right.indexOf('node7-x6') >= 0); assert(right.indexOf('Unknown token') >= 0); ================================================ FILE: test/test-50-invalid-unknown-token/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-50-many-arrow-functions/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './test-output.exe'; const arch = process.arch; // TODO extract arch from `target` once it contains if (arch === 'arm') return; const version1 = process.version; if (/^(node|v)?0/.test(version1)) return; const version2 = target; if (/^(node|v)?0/.test(version2)) return; let left, right; left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-many-arrow-functions/test-x-index.js ================================================ 'use strict'; function EventEmitter() { this.listeners = []; } EventEmitter.prototype.on = function (name, listener) { this.listeners.push(listener); }; EventEmitter.prototype.emit = function (name, data) { this.listeners.some((listener) => { listener(data); }); }; const ee = new EventEmitter(); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.on('message', (data) => { console.log(data); }); ee.emit('message', 'hooray'); ================================================ FILE: test/test-50-many-arrow-functions/test-z-creator.js ================================================ 'use strict'; let s = 'function EventEmitter () {\n' + ' this.listeners = [];\n' + '}\n' + 'EventEmitter.prototype.on = function (name, listener) {\n' + ' this.listeners.push(listener);\n' + '};\n' + 'EventEmitter.prototype.emit = function (name, data) {\n' + ' this.listeners.some((listener) => {\n' + ' listener(data);\n' + ' });\n' + '};\n' + 'const ee = new EventEmitter();\n'; for (let i = 0; i < 140; i += 1) { s += "ee.on('message', (data) => {\n console.log(data);\n});\n"; } s += "ee.emit('message', 'hooray');\n"; s = "'use strict';\n\n" + s; require('fs').writeFileSync('test-x-index.js', s); ================================================ FILE: test/test-50-many-callbacks/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; if (process.arch === 'arm') return; let left, right; left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-many-callbacks/test-x-index.js ================================================ 'use strict'; setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout(function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { setTimeout( function () { console.log( 'test' ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0 ); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); }, 0); ================================================ FILE: test/test-50-many-callbacks/test-z-creator.js ================================================ 'use strict'; let s = "console.log('test');\n"; for (let i = 0; i < 100; i += 1) { s = 'setTimeout(function () {\n' + s + '}, 0);\n'; } s = "'use strict';\n\n" + s; require('fs').writeFileSync('test-x-index.js', s); ================================================ FILE: test/test-50-may-exclude/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-may-exclude/test-x-index.js ================================================ 'use strict'; // 1 var error1; function func1() { require.resolve('not-exists-1', 'may-exclude'); } try { func1(); } catch (e) { error1 = e; } // 2 var error2; function func2() { require.resolve('not-exists-2', 'may-exclude'); } try { func2(); } catch (e) { error2 = e; } // 3 var error3; try { require.resolve('not-exists-3'); } catch (e) { error3 = e; } // 4 var error4; try { if (process.env.HELLO !== 'WORLD') { require.resolve('not-exists-4'); } } catch (e) { error4 = e; } console.log( [ error1.message.split('\n')[0], error1.code, JSON.stringify(Object.assign(error1, { requireStack: undefined })), error2.message.split('\n')[0], error2.code, JSON.stringify(Object.assign(error2, { requireStack: undefined })), error3.message.split('\n')[0], error3.code, JSON.stringify(Object.assign(error3, { requireStack: undefined })), error4.message.split('\n')[0], error4.code, JSON.stringify(Object.assign(error4, { requireStack: undefined })), ].join('\n') ); ================================================ FILE: test/test-50-may-exclude-must-exclude/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; const standard = 'stdout'; let right; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync( ['--debug', '--target', target, '--output', output, input], inspect ); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); right = right .split('\n') .filter(function (line) { return line.indexOf(' [debug] ') >= 0 || line.indexOf(' Warning ') >= 0; }) .filter(function (line) { return ( line.indexOf('Targets:') < 0 && line.indexOf('added to queue') < 0 && line.indexOf('was included') < 0 ); }) .map(function (line) { if (line.indexOf('Cannot find module') >= 0) { return line.split(' from ')[0]; } else return line; }) .join('\n') + '\n'; assert.deepStrictEqual(right.split('\n').slice(0, 16), [ "> Warning Cannot resolve 'reqResSomeVar'", "> [debug] Cannot resolve 'reqResSomeVarMay'", "> Warning Malformed requirement for 'reqResSomeVar'", "> Warning Malformed requirement for 'reqResSomeVar'", "> Warning Cannot resolve 'reqSomeVar'", "> [debug] Cannot resolve 'reqSomeVarMay'", "> Warning Malformed requirement for 'reqSomeVar'", "> Warning Malformed requirement for 'reqSomeVar'", "> [debug] Cannot resolve 'tryReqResSomeVar'", "> [debug] Cannot resolve 'tryReqResSomeVarMay'", "> [debug] Cannot resolve 'tryReqSomeVar'", "> [debug] Cannot resolve 'tryReqSomeVarMay'", "> [debug] Cannot find module 'reqResSomeLit'", "> [debug] Cannot find module 'reqResSomeLitMay'", "> [debug] Cannot find module 'reqSomeLit'", "> [debug] Cannot find module 'reqSomeLitMay'", ]); utils.vacuum.sync(output); ================================================ FILE: test/test-50-may-exclude-must-exclude/test-x-index.js ================================================ /* eslint-disable max-statements-per-line */ /* eslint-disable no-empty */ 'use strict'; try { require.resolve('reqResSomeLit'); } catch (_) {} try { require.resolve('reqResSomeLitMay', 'may-exclude'); } catch (_) {} try { require.resolve('reqResSomeLitMust', 'must-exclude'); } catch (_) {} try { require('reqSomeLit'); } catch (_) {} try { require('reqSomeLitMay', 'may-exclude'); } catch (_) {} try { require('reqSomeLitMust', 'must-exclude'); } catch (_) {} var tryReqResSomeVar = 'some'; var tryReqResSomeVarMay = 'some'; var tryReqResSomeVarMust = 'some'; var tryReqSomeVar = 'some'; var tryReqSomeVarMay = 'some'; var tryReqSomeVarMust = 'some'; try { require.resolve(tryReqResSomeVar); } catch (_) {} try { require.resolve(tryReqResSomeVarMay, 'may-exclude'); } catch (_) {} try { require.resolve(tryReqResSomeVarMust, 'must-exclude'); } catch (_) {} try { require(tryReqSomeVar); } catch (_) {} try { require(tryReqSomeVarMay, 'may-exclude'); } catch (_) {} try { require(tryReqSomeVarMust, 'must-exclude'); } catch (_) {} var reqResSomeVar = 'some'; var reqResSomeVarMay = 'some'; var reqResSomeVarMust = 'some'; var reqSomeVar = 'some'; var reqSomeVarMay = 'some'; var reqSomeVarMust = 'some'; require.resolve(reqResSomeVar); require.resolve(reqResSomeVarMay, 'may-exclude'); require.resolve(reqResSomeVarMust, 'must-exclude'); require.resolve(reqResSomeVar, reqResSomeVar); require.resolve(reqResSomeVar, 'can-can'); require(reqSomeVar); require(reqSomeVarMay, 'may-exclude'); require(reqSomeVarMust, 'must-exclude'); require(reqSomeVar, reqSomeVar); require(reqSomeVar, 'can-can'); require.resolve('./test-y-index.js'); require('./test-y-index.js'); ================================================ FILE: test/test-50-may-exclude-must-exclude/test-y-index.js ================================================ 'use strict'; module.exports = 'hello'; ================================================ FILE: test/test-50-module-parent/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); left = left.split('\n'); right = right.split('\n'); // right may have less lines, premature exit, // less trusted, so using left.length here for (let i = 0; i < left.length; i += 1) { assert.strictEqual(left[i], right[i]); } utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-module-parent/test-x-index.js ================================================ 'use strict'; require('./test-y-fish-A.js'); require('./test-y-fish-B.js'); ================================================ FILE: test/test-50-module-parent/test-y-fish-A.js ================================================ 'use strict'; console.log('test-y-fish-A'); console.log(require('./test-y-fish-C')); ================================================ FILE: test/test-50-module-parent/test-y-fish-B.js ================================================ 'use strict'; console.log('test-y-fish-B'); console.log(require('./test-y-fish-C')); ================================================ FILE: test/test-50-module-parent/test-y-fish-C.js ================================================ 'use strict'; var path = require('path'); var mpfn = module.parent.filename; module.exports = mpfn.split(path.sep).slice(-2).join(path.sep); ================================================ FILE: test/test-50-mountpoints/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let right; utils.mkdirp.sync(path.dirname(output)); utils.mkdirp.sync(path.join(path.dirname(output), 'plugins-D-ext')); fs.writeFileSync( path.join(path.dirname(output), 'plugins-D-ext/test-y-require-D.js'), fs.readFileSync('./plugins-D-ext/test-y-require-D.js') ); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual( right, 'I am C\n' + 'I am D\n' + 'test-x-index.js\n' + 'test-y-common.js\n' + 'plugins-C-int\n' + 'plugins-D-ext\n' ); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-mountpoints/plugins-C-int/test-y-require-C.js ================================================ 'use strict'; var common = require('../test-y-common.js'); common('I am C'); ================================================ FILE: test/test-50-mountpoints/plugins-D-ext/test-y-require-D.js ================================================ 'use strict'; var assert = require('assert'); var common = require('../test-y-common.js'); if (__dirname.indexOf('snapshot') < 0) { console.log(__dirname); assert(false); } common('I am D'); ================================================ FILE: test/test-50-mountpoints/test-x-index.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); require('./plugins-C-int/test-y-require-C.js'); // require(path.join(path.dirname(process.execPath), "plugins-D-ext/test-y-require-D.js")); var myDirectory = path.dirname(process.execPath); process.pkg.mount( path.join(__dirname, 'plugins-D-ext'), path.join(myDirectory, 'plugins-D-ext') ); require('./plugins-D-ext/test-y-require-D.js'.slice()); console.log(fs.readdirSync(__dirname).join('\n')); ================================================ FILE: test/test-50-mountpoints/test-y-common.js ================================================ 'use strict'; module.exports = function (s) { console.log(s); }; ================================================ FILE: test/test-50-native-addon/lib/time.node ================================================ module.exports = 'test'; ================================================ FILE: test/test-50-native-addon/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); fs.writeFileSync( path.join(path.dirname(output), 'time.node'), fs.readFileSync('./lib/time.node') ); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-native-addon/test-x-index.js ================================================ /* eslint-disable no-underscore-dangle */ 'use strict'; var fs = require('fs'); var path = require('path'); var Module = require('module'); Module._extensions['.node'] = Module._extensions['.js']; console.log(fs.existsSync(path.join(__dirname, 'lib/time.node'))); console.log(require('./lib/time.node')); ================================================ FILE: test/test-50-native-addon-2/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './test-output.exe'; let left, right; left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-native-addon-2/test-x-index.js ================================================ /* eslint-disable no-underscore-dangle */ 'use strict'; var fs = require('fs'); var path = require('path'); var Module = require('module'); Module._extensions['.node'] = Module._extensions['.js']; console.log( fs.existsSync(path.join(__dirname, 'node_modules/dependency/time.node')) ); console.log(require('dependency/time.node')); ================================================ FILE: test/test-50-native-addon-3/lib/community/test-y-index.js ================================================ /* eslint-disable no-underscore-dangle */ 'use strict'; var Module = require('module'); Module._extensions['.node'] = Module._extensions['.js']; console.log(require('dependency/time-d.node')); console.log(require('../time-x.node')); console.log(require('./time-y.node')); ================================================ FILE: test/test-50-native-addon-3/lib/community/time-y.node ================================================ module.exports = 'time-y'; ================================================ FILE: test/test-50-native-addon-3/lib/enterprise/test-z-index.js ================================================ /* eslint-disable no-underscore-dangle */ 'use strict'; var Module = require('module'); Module._extensions['.node'] = Module._extensions['.js']; console.log(require('dependency/time-d.node')); console.log(require('../time-x.node')); console.log(require('../../lib/enterprise/time-z.node')); ================================================ FILE: test/test-50-native-addon-3/lib/enterprise/time-z.node ================================================ module.exports = 'time-z'; ================================================ FILE: test/test-50-native-addon-3/lib/test-x-index.js ================================================ /* eslint-disable no-underscore-dangle */ 'use strict'; var fs = require('fs'); var path = require('path'); var Module = require('module'); Module._extensions['.node'] = Module._extensions['.js']; console.log( fs.existsSync(path.join(__dirname, '../node_modules/dependency/time-d.node')) ); console.log(require('dependency/time-d.node')); console.log(fs.existsSync(path.join(__dirname, 'time-x.node'))); console.log(require('./time-x.node')); console.log(fs.existsSync(path.join(__dirname, 'community/time-y.node'))); console.log(require('./community/time-y.node')); console.log( fs.existsSync(path.join(__dirname, '../lib/enterprise/time-z.node')) ); console.log(require('../lib/enterprise/time-z.node')); ================================================ FILE: test/test-50-native-addon-3/lib/time-x.node ================================================ module.exports = 'test'; ================================================ FILE: test/test-50-native-addon-3/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const pairs = [ { input: './lib/test-x-index.js', output: './lib/test-output.exe' }, { input: './lib/test-x-index.js', output: './lib/community/test-output.exe' }, { input: './lib/test-x-index.js', output: './lib/enterprise/test-output.exe', }, { input: './lib/community/test-y-index.js', output: './lib/community/test-output.exe', }, { input: './lib/enterprise/test-z-index.js', output: './lib/enterprise/test-output.exe', }, ]; pairs.some(function (pair) { const input = pair.input; const output = pair.output; let left, right; left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); }); ================================================ FILE: test/test-50-native-addon-4/lib/time.node ================================================ module.exports = 'test'; ================================================ FILE: test/test-50-native-addon-4/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-native-addon-4/test-x-index.js ================================================ /* eslint-disable no-underscore-dangle */ 'use strict'; var fs = require('fs'); var path = require('path'); var Module = require('module'); Module._extensions['.node'] = Module._extensions['.js']; console.log(fs.existsSync(path.join(__dirname, 'lib/time.node'))); console.log(require('./lib/time.node')); ================================================ FILE: test/test-50-no-signature/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const darwin = process.platform === 'darwin'; if (!darwin) { return; } const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output'; let right; utils.pkg.sync([ '--no-signature', '--target', target, '--output', output, input, ]); right = utils.spawn.sync('codesign', ['-dv', './' + path.basename(output)], { stdio: 'pipe', expect: 1, }); assert.strictEqual( right.stderr, './test-output: code object is not signed at all\n' ); utils.vacuum.sync(output); ================================================ FILE: test/test-50-no-signature/test-x-index.js ================================================ 'use strict'; console.log('ok'); ================================================ FILE: test/test-50-no-super-in-constructor/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './test-output.exe'; if (/^(node|v)?0/.test(target)) return; if (/^(node|v)?4/.test(target)) return; let right; utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(right, 'ok\n'); utils.vacuum.sync(output); ================================================ FILE: test/test-50-no-super-in-constructor/test-x-index.js ================================================ 'use strict'; var events = require('events'); var util = require('util'); class UpnpService { constructor() { console.log('ok'); events.EventEmitter.call(this); } } util.inherits(UpnpService, events.EventEmitter); const u = new UpnpService(); if (!u) throw new Error('hello'); ================================================ FILE: test/test-50-node-modules-tree/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-node-modules-tree/test-x-index.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); console.log( [ require('./test-y-fish-A'), require('test-y-fish-B'), // fs.readFileSync(require.resolve("./test-y-fish-E"), "utf8"), // fs.readFileSync(require.resolve("test-y-fish-F"), "utf8"), fs.readFileSync(path.join(__dirname, './test-y-fish-G'), 'utf8'), fs.readFileSync(path.join(__dirname, 'test-y-fish-H'), 'utf8'), fs.existsSync('./test-y-fish-C').toString(), fs.existsSync('test-y-fish-D').toString(), // fs.existsSync(require.resolve("./test-y-fish-E")).toString(), // fs.existsSync(require.resolve("test-y-fish-F")).toString(), fs.existsSync(path.join(__dirname, './test-y-fish-G')).toString(), fs.existsSync(path.join(__dirname, 'test-y-fish-H')).toString(), require('test-y-fish-I'), // разница в node_modules\test-y-fish-I\index.js require('test-y-fish-J'), JSON.stringify(require('test-y-fish-M')), JSON.stringify(require('test-y-fish-N')), require('test-y-fish-O'), require('test-y-fish-P'), require('test-y-fish-R'), ].join('\n') ); ================================================ FILE: test/test-50-node-modules-tree/test-y-fish-A.js ================================================ 'use strict'; module.exports = 'test-y-fish-A-supfile'; ================================================ FILE: test/test-50-node-modules-tree/test-y-fish-B.js ================================================ 'use strict'; module.exports = 'test-y-fish-B-supfile'; ================================================ FILE: test/test-50-node-modules-tree/test-y-fish-E ================================================ test-y-fish-E-supfile ================================================ FILE: test/test-50-node-modules-tree/test-y-fish-F ================================================ test-y-fish-F-supfile ================================================ FILE: test/test-50-node-modules-tree/test-y-fish-G ================================================ test-y-fish-G-supfile ================================================ FILE: test/test-50-node-modules-tree/test-y-fish-H ================================================ test-y-fish-H-supfile ================================================ FILE: test/test-50-node-modules-tree/test-y-fish-I ================================================ test-y-fish-I-supfile ================================================ FILE: test/test-50-node-modules-tree/test-y-fish-J ================================================ test-y-fish-J-supfile ================================================ FILE: test/test-50-node-modules-tree/test-y-fish-M ================================================ test-y-fish-M-supfile ================================================ FILE: test/test-50-node-modules-tree/test-y-fish-N ================================================ test-y-fish-N-supfile ================================================ FILE: test/test-50-node-modules-tree/test-y-fish-O ================================================ test-y-fish-O-supfile ================================================ FILE: test/test-50-node-modules-tree/test-y-fish-P ================================================ test-y-fish-P-supfile ================================================ FILE: test/test-50-non-ascii/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './АБРАКАДАБРА/test-output.exe'; // cyrillic let right; utils.mkdirp.sync(path.dirname(output)); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync(output, [], {}); assert.strictEqual(right, '42\n42\n'); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-non-ascii/test-x-index.js ================================================ 'use strict'; console.log(42); require('./test-y-$$'); ================================================ FILE: test/test-50-non-ascii/test-y-$$.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-50-not-found-wording/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let right; utils.mkdirp.sync(path.dirname(output)); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert( right .split('*****')[0] .indexOf('was not included into executable at compilation stage') >= 0 ); assert(right.split('*****')[1].indexOf('you want to compile the package') >= 0); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-not-found-wording/test-x-index.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); var name = path.join(__dirname, 'not' + 'exists'); // eslint-disable-line no-useless-concat try { fs.readFileSync(name); } catch (e) { console.log(e.message); } console.log('*****'); try { require('not-exists'); } catch (e) { console.log(e.message); } ================================================ FILE: test/test-50-not-found-wording-2/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-not-found-wording-2/test-x-index.js ================================================ 'use strict'; var name = 'not-exists'; var error1, error2; try { require.resolve(name); } catch (e) { error1 = e; } try { require(name); } catch (e) { error2 = e; } console.log( [ error1.message.split('\n')[0], error1.code, error2.message.split('\n')[0], error2.code, ].join('\n') ); ================================================ FILE: test/test-50-object-spread/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './test-output.exe'; if (/^(node|v)?0/.test(target)) return; if (/^(node|v)?4/.test(target)) return; if (/^(node|v)?6/.test(target)) return; let right; utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(right, 'ok\n'); utils.vacuum.sync(output); ================================================ FILE: test/test-50-object-spread/test-x-index.js ================================================ 'use strict'; var s = { o: 'o', k: 'k' }; var { o, ...other } = s; var fn = ({ x, ...y }) => x(y.value); fn({ x: console.log, value: o + other.k }); ================================================ FILE: test/test-50-observe-snapshot-root/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let right; utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(right, 'ok\n'); utils.vacuum.sync(output); ================================================ FILE: test/test-50-observe-snapshot-root/test-x-index.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); if (process.platform === 'win32') { var root = path.parse(process.argv[1]).root; // D:\\ if (fs.statSync(root + 'snapshot').isDirectory()) { var root2 = root.slice(0, 2) + '/'; if (fs.statSync(root2 + 'snapshot').isDirectory()) { try { fs.statSync('/snapshot'); } catch (error) { if (error.code === 'ENOENT') { console.log('ok'); } } } } } else { if (fs.statSync('/snapshot').isDirectory()) { try { fs.statSync('K:\\snapshot'); } catch (error) { if (error.code === 'ENOENT') { console.log('ok'); } } } } ================================================ FILE: test/test-50-observe-snapshot-root-2/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let right; utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(right, 'ok\n'); utils.vacuum.sync(output); ================================================ FILE: test/test-50-observe-snapshot-root-2/test-x-index.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); if (process.platform === 'win32') { var root = path.parse(process.argv[1]).root; // D:\\ if (fs.readdirSync(root).indexOf('snapshot') >= 0) { var root2 = root.slice(0, 2) + '/'; if (fs.readdirSync(root2).indexOf('snapshot') >= 0) { fs.readdir(root, function (error, entries) { if (error) throw error; if (entries.indexOf('snapshot')) { fs.readdir(root2, function (error2, entries2) { if (error2) throw error2; if (entries2.indexOf('snapshot')) { console.log('ok'); } }); } }); } } } else { if (fs.readdirSync('/').indexOf('snapshot') >= 0) { fs.readdir('/', function (error, entries) { if (error) throw error; if (entries.indexOf('snapshot')) { console.log('ok'); } }); } } ================================================ FILE: test/test-50-odd-entrypoint/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const windows = process.platform === 'win32'; let input = './test-x-index.js'; const output = './run-time/test-output.exe'; if (windows) { input = path.resolve(input).toLowerCase(); } else { // did not manage to find odd one for unix } let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-odd-entrypoint/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-50-package-a-binary/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-package-a-binary/test-x-index.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); var crypto = require('crypto'); function sha256(s) { return crypto.createHash('sha256').update(s).digest('hex'); } var file = fs.readFileSync(path.join(__dirname, 'test-y-binary.png')); console.log(sha256(file)); // 72c388896ca159d734244fcf556cc7e06adb255ff09d5eb721f144066a65d3b0 ================================================ FILE: test/test-50-package-json/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-package-json/package.json ================================================ { "bin": "test-x-index.js", "pkg": { "scripts": "test-y-*" } } ================================================ FILE: test/test-50-package-json/test-x-index.js ================================================ /* eslint-disable no-useless-concat */ 'use strict'; var theA = './test-y-' + 'resolve-A.js'; var theB = './test-y-' + 'resolve-B.txt'; var theC = './test-y-' + 'resolve-C.json'; console.log( [ require(theA).toString(), require(theB).toString(), require(theC).toString(), ].join('\n') ); ================================================ FILE: test/test-50-package-json/test-y-resolve-A.js ================================================ 'use strict'; module.exports = 'test-y-resolve-A'; ================================================ FILE: test/test-50-package-json/test-y-resolve-B.txt ================================================ module.exports = "test-y-resolve-B"; ================================================ FILE: test/test-50-package-json/test-y-resolve-C.json ================================================ "test-y-resolve-C" ================================================ FILE: test/test-50-package-json-2/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', ['sub/test-x-index.js']); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-package-json-2/package.json ================================================ { "bin": "sub/test-x-index.js", "pkg": { "scripts": "./test-y-data.json" } } ================================================ FILE: test/test-50-package-json-2/sub/test-x-index.js ================================================ 'use strict'; var dataPath = '../test-y-data.json'; var data = require(dataPath); console.log(data); ================================================ FILE: test/test-50-package-json-2/test-y-data.json ================================================ "test data" ================================================ FILE: test/test-50-package-json-3/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const output = './test-output.exe'; let left, right; left = utils.spawn.sync('node', ['test-x-index.js']); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-package-json-3/package.json ================================================ { "bin": "test-x-index.js", "pkg": { "patches": { "test-x-index.js": [ "require(__dirname + '/' + dataPath);", "require(process.cwd() + '/' + dataPath);" ] } } } ================================================ FILE: test/test-50-package-json-3/test-x-index.js ================================================ /* eslint-disable no-path-concat */ 'use strict'; var dataPath = 'test-y-data.json'; var data = require(__dirname + '/' + dataPath); console.log(data); ================================================ FILE: test/test-50-package-json-3/test-y-data.json ================================================ "test data" ================================================ FILE: test/test-50-package-json-4/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-package-json-4/test-x-index.js ================================================ 'use strict'; require('busboy'); var dataPath1 = 'busboy/lib/types/test-y-require.js'; var data1 = require(dataPath1); console.log(data1); require('log4js/index.js'); var dataPath2 = 'log4js/lib/appenders/test-z-require.js'; var data2 = require(dataPath2); console.log(data2); ================================================ FILE: test/test-50-package-json-5/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './node_modules/input/test-x-index.js'; const output = './test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-package-json-6/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-package-json-6/test-x-index.js ================================================ 'use strict'; require('./node_modules/alpha'); ================================================ FILE: test/test-50-package-json-6b/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './node_modules/alpha/alpha.js'; const output = './test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-package-json-6c/beta/alpha.js ================================================ 'use strict'; require('../beta'); if (process.pkg && require('path').sep === '/') { if (__dirname === '/snapshot/pkg/test/test-50-package-json-6c/beta') { try { console.log( require('fs').readFileSync('/snapshot/pkg/package.json', 'utf-8') ); } catch (_) { // must not take pkg/package.json into executable } } else { require('assert')(__dirname === '/snapshot/beta'); } } ================================================ FILE: test/test-50-package-json-6c/beta/beta.js ================================================ 'use strict'; console.log('bar'); ================================================ FILE: test/test-50-package-json-6c/beta/package.json ================================================ { "name": "beta", "main": "beta.js" } ================================================ FILE: test/test-50-package-json-6c/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './beta/alpha.js'; const output = './test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-package-json-6d/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-package-json-6d/test-x-index.js ================================================ 'use strict'; require('alpha'); ================================================ FILE: test/test-50-package-json-7/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const output = './test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', ['test-x-index.js']); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-package-json-7/package.json ================================================ { "bin": "test-x-index.js", "dependencies": { "delta": "*", "normalize.css": "*" } } ================================================ FILE: test/test-50-package-json-7/test-x-index.js ================================================ 'use strict'; var fs = require('fs'); var dataPath1 = 'delta'; require(dataPath1); console.log(global.FOO); var dataPath2 = 'normalize.css'; var css = fs.readFileSync(require.resolve(dataPath2), 'utf8'); console.log(css); ================================================ FILE: test/test-50-package-json-7p/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const output = './test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', ['test-x-index.js']); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-package-json-7p/package.json ================================================ { "bin": "test-x-index.js", "license": "MIT", "dependencies": { "delta": "*" } } ================================================ FILE: test/test-50-package-json-7p/test-x-index.js ================================================ 'use strict'; var dataPath = 'delta'; require(dataPath); console.log(global.FOO); ================================================ FILE: test/test-50-package-json-8/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', ['sub/test-x-index.js']); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-package-json-8/package.json ================================================ { "bin": "sub/test-x-index.js", "files": [ "sub/sub", "test-z-data.css" ] } ================================================ FILE: test/test-50-package-json-8/sub/sub/test-y-require.js ================================================ 'use strict'; var assert = require('assert'); function main() { require('../test-z-require.js'); } if (process.pkg) { assert(main.toString().indexOf('test') < 0); } main(); ================================================ FILE: test/test-50-package-json-8/sub/test-x-index.js ================================================ 'use strict'; var dataPath = './sub/test-y-require.js'; require(dataPath); ================================================ FILE: test/test-50-package-json-8/sub/test-z-require.js ================================================ 'use strict'; var fs = require('fs'); var dataPath = '../test-z-data.css'; var data = fs.readFileSync(require.resolve(dataPath), 'utf8'); console.log(data); ================================================ FILE: test/test-50-package-json-8/test-z-data.css ================================================ test data ================================================ FILE: test/test-50-package-json-8b/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', ['sub/test-x-index.js']); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-package-json-8b/package.json ================================================ { "bin": "sub/test-x-index.js", "files": [ "/sub/sub", "/test-z-data.css" ] } ================================================ FILE: test/test-50-package-json-8b/sub/sub/test-y-require.js ================================================ 'use strict'; var assert = require('assert'); function main() { require('../test-z-require.js'); } if (process.pkg) { assert(main.toString().indexOf('test') < 0); } main(); ================================================ FILE: test/test-50-package-json-8b/sub/test-x-index.js ================================================ 'use strict'; var dataPath = './sub/test-y-require.js'; require(dataPath); ================================================ FILE: test/test-50-package-json-8b/sub/test-z-require.js ================================================ 'use strict'; var fs = require('fs'); var dataPath = '../test-z-data.css'; var data = fs.readFileSync(require.resolve(dataPath), 'utf8'); console.log(data); ================================================ FILE: test/test-50-package-json-8b/test-z-data.css ================================================ test data ================================================ FILE: test/test-50-package-json-8p/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', ['sub/test-x-index.js']); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-package-json-8p/package.json ================================================ { "bin": "sub/test-x-index.js", "pkg": { "scripts": [ "sub/sub" ], "assets": [ "test-z-data.css" ] } } ================================================ FILE: test/test-50-package-json-8p/sub/sub/test-y-require.js ================================================ 'use strict'; var assert = require('assert'); function main() { require('../test-z-require.js'); } if (process.pkg) { assert(main.toString().indexOf('test') < 0); } main(); ================================================ FILE: test/test-50-package-json-8p/sub/test-x-index.js ================================================ 'use strict'; var dataPath = './sub/test-y-require.js'; require(dataPath); ================================================ FILE: test/test-50-package-json-8p/sub/test-z-require.js ================================================ 'use strict'; var fs = require('fs'); var dataPath = '../test-z-data.css'; var data = fs.readFileSync(require.resolve(dataPath), 'utf8'); console.log(data); ================================================ FILE: test/test-50-package-json-8p/test-z-data.css ================================================ test data ================================================ FILE: test/test-50-package-json-9/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-package-json-9/test-x-index.js ================================================ 'use strict'; require('test-y-require'); ================================================ FILE: test/test-50-package-json-9p/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-package-json-9p/test-x-index.js ================================================ 'use strict'; require('test-y-require'); ================================================ FILE: test/test-50-package-json-A/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-package-json-A/package.json ================================================ { "bin": "test-x-index.js", "data": 42 } ================================================ FILE: test/test-50-package-json-A/test-x-index.js ================================================ /* eslint-disable no-useless-concat */ 'use strict'; var thePJ = './package' + '.json'; console.log(require(thePJ).data); ================================================ FILE: test/test-50-path-as-buffer/main.js ================================================ #!/usr/bin/env node /* eslint-disable no-multi-spaces */ 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './test-output.exe'; function isNode8(version) { return /^(node|v)?8/.test(version); } const version1 = process.version; const version2 = target; if (isNode8(version1) === isNode8(version2)) { let left, right; left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); } ================================================ FILE: test/test-50-path-as-buffer/test-x-index.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); var hasURL = typeof URL !== 'undefined'; var d = __dirname; var f = path.join(__dirname, 'test-z-asset.css'); console.log(fs.statSync(f).size); console.log(fs.statSync(Buffer.from(f)).size); if (hasURL) console.log(fs.statSync(new URL('file://' + f)).size); console.log(fs.readdirSync(d).includes('test-z-asset.css')); console.log(fs.readdirSync(Buffer.from(d)).includes('test-z-asset.css')); if (hasURL) console.log( fs.readdirSync(new URL('file://' + d)).includes('test-z-asset.css') ); ================================================ FILE: test/test-50-path-as-buffer/test-z-asset.css ================================================ .header { background: #444; } ================================================ FILE: test/test-50-path-separators/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', ['test-x-index.js']); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-path-separators/package.json ================================================ { "bin": "test-x-index.js", "pkg": { "assets": "sub/*" } } ================================================ FILE: test/test-50-path-separators/sub/test-y-require-C.js ================================================ 'use strict'; module.exports = []; ================================================ FILE: test/test-50-path-separators/sub/test-y-require-D.js ================================================ 'use strict'; module.exports = []; ================================================ FILE: test/test-50-path-separators/test-x-index.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); console.log( fs.readdirSync(path.join(__dirname, 'sub')), fs.readdirSync(path.join(__dirname, 'sub/')), fs.readdirSync(path.join(__dirname, 'sub//')) ); ================================================ FILE: test/test-50-promisify/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './test-output.exe'; let left, right; left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(output); ================================================ FILE: test/test-50-promisify/test-x-index.js ================================================ 'use strict'; var promisify = require('util').promisify; if (!promisify) return console.log('ok'); var fs = require('fs'); var execAsync = promisify(require('child_process').exec); var existsAsync = promisify(fs.exists); var readAsync = promisify(fs.read); execAsync('whoami').then(function (output) { console.log(JSON.stringify(output)); existsAsync('./main.js').then(function (existence) { console.log(existence); fs.open('./main.js', 'r', function (error, fd) { if (error) return; readAsync(fd, Buffer.alloc(10), 0, 10, 0).then(function (tuple) { console.log(JSON.stringify(tuple)); }); }); }); }); ================================================ FILE: test/test-50-public-packages/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; const input = './test-x-index.js'; const output = './test-output.exe'; if (/^(node|v)?0/.test(target)) return; for (const pub of ['swordsman', 'crusader', '*']) { let right; utils.pkg.sync([ '--public-packages=' + pub, '--target', target, '--output', output, input, ]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); if (pub === 'swordsman') { assert.strictEqual(right, ''); } else { assert.strictEqual(right, 'ok\n'); } utils.vacuum.sync(output); } ================================================ FILE: test/test-50-public-packages/test-x-index.js ================================================ 'use strict'; require('crusader'); ================================================ FILE: test/test-50-reproducible/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output1 = './test-output-1.exe'; const output2 = './test-output-2.exe'; // v8 introduced random bits in snapshots // version 6.0 (nodejs 8.3.0) // TODO make v8 nullify pointers upon serializing utils.pkg.sync([ '--public', '--no-signature', // the signature will make the build not reproducible '--no-bytecode', '--target', target, '--output', output1, input, ]); utils.pkg.sync([ '--public', '--no-signature', '--no-bytecode', '--target', target, '--output', output2, input, ]); const content1 = fs.readFileSync(output1); const content2 = fs.readFileSync(output2); assert.strictEqual(Buffer.compare(content1, content2), 0); utils.vacuum.sync(output1); utils.vacuum.sync(output2); ================================================ FILE: test/test-50-reproducible/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-50-require-edge-cases/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-require-edge-cases/test-x-index.js ================================================ 'use strict'; var path = require('path'); var content = path.join(__dirname, 'test-x1-content.js'); console.log( [ require(content), require('./test-x2-require-false.js'), typeof require('./test-x3-empty-file.js'), ].join('\n') ); ================================================ FILE: test/test-50-require-edge-cases/test-x1-content.js ================================================ 'use strict'; module.exports = 'hello'; ================================================ FILE: test/test-50-require-edge-cases/test-x2-require-false.js ================================================ 'use strict'; module.exports = false; ================================================ FILE: test/test-50-require-edge-cases/test-x3-empty-file.js ================================================ ================================================ FILE: test/test-50-require-main-parent/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); // это директории. под // виндой они case-insensitive left = left.toLowerCase(); right = right.toLowerCase(); left = left.split('\n'); right = right.split('\n'); assert.strictEqual(left.length, right.length); assert(left.length > 100); var nonSnapshot; left.some(function (leftValue, index) { const rightValue = right[index]; if (leftValue.slice(1, 3) === ':\\') { assert.strictEqual(rightValue.slice(1, 12), ':\\snapshot\\'); nonSnapshot = rightValue.length - 12; assert.strictEqual( leftValue.slice(-nonSnapshot), rightValue.slice(-nonSnapshot) ); } else if (leftValue.slice(0, 1) === '/') { assert.strictEqual(rightValue.slice(0, 10), '/snapshot/'); nonSnapshot = rightValue.length - 10; assert.strictEqual( leftValue.slice(-nonSnapshot), rightValue.slice(-nonSnapshot) ); } else if (leftValue === '') { assert.strictEqual(leftValue, rightValue); } else if (leftValue === 'empty') { assert.strictEqual(leftValue, rightValue); } else if (leftValue === 'string') { assert.strictEqual(leftValue, rightValue); } else if (leftValue === 'object') { assert.strictEqual(leftValue, rightValue); } else if (leftValue === 'function') { assert.strictEqual(leftValue, rightValue); } else if (leftValue === 'true') { assert.strictEqual(leftValue, rightValue); } else if (leftValue === 'false') { assert.strictEqual(leftValue, rightValue); } else if (leftValue === 'null') { assert.strictEqual(leftValue, rightValue); } else { console.log(leftValue, rightValue); assert(false); } }); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-require-main-parent/sub/test-y-require-C.js ================================================ /* eslint-disable no-nested-ternary */ 'use strict'; module.exports = [ __dirname, __filename, typeof module.filename, module.filename ? module.filename : 'empty', typeof module.parent, module.parent ? typeof module.parent.filename : 'empty', module.parent ? module.parent.filename ? module.parent.filename : 'empty' : 'empty', typeof module.require, typeof global, // в nodejs они разные // (module.require === require).toString(), typeof require.main, (require.main === module).toString(), typeof require.main.parent, (require.main.parent || 'null').toString(), require.main.parent ? require.main.parent.id : 'empty', require.main.parent ? require.main.parent.filename : 'empty', typeof global, typeof global.setTimeout, global.module ? (global.module === module).toString() : 'true', global.require ? (global.require === require).toString() : 'true', ]; ================================================ FILE: test/test-50-require-main-parent/sub/test-y-require-D.js ================================================ /* eslint-disable no-nested-ternary */ 'use strict'; module.exports = [ __dirname, __filename, typeof module.filename, module.filename ? module.filename : 'empty', typeof module.parent, module.parent ? typeof module.parent.filename : 'empty', module.parent ? module.parent.filename ? module.parent.filename : 'empty' : 'empty', typeof module.require, typeof global, // в nodejs они разные // (module.require === require).toString(), typeof require.main, (require.main === module).toString(), typeof require.main.parent, (require.main.parent || 'null').toString(), require.main.parent ? require.main.parent.id : 'empty', require.main.parent ? require.main.parent.filename : 'empty', typeof global, typeof global.setTimeout, global.module ? (global.module === module).toString() : 'true', global.require ? (global.require === require).toString() : 'true', ]; ================================================ FILE: test/test-50-require-main-parent/test-x-index.js ================================================ /* eslint-disable no-nested-ternary */ 'use strict'; var fs = require('fs'); console.log( [ typeof process.argv[0], typeof process.argv[1], process.platform === 'win32' ? fs.existsSync(process.argv[0]) : 'empty', fs.existsSync(process.argv[1]), // argv[0] is just "node" in linux __dirname, __filename, typeof module.filename, module.filename ? module.filename : 'empty', typeof module.parent, module.parent ? typeof module.parent.filename : 'empty', module.parent ? module.parent.filename ? module.parent.filename : 'empty' : 'empty', typeof module.require, typeof global, // в nodejs они разные // (module.require === require).toString(), typeof require.main, (require.main === module).toString(), typeof require.main.parent, (require.main.parent || 'null').toString(), require.main.parent ? require.main.parent.id : 'empty', require.main.parent ? require.main.parent.filename : 'empty', typeof require.cache, typeof global, typeof global.setTimeout, global.module ? (global.module === module).toString() : 'true', global.require ? (global.require === require).toString() : 'true', ] /**/ .concat(require('./test-y-require-A.js')) .concat(require('./test-y-require-A.js')) .concat(require('../test-50-require-main-parent/test-y-require-B.js')) .concat(require('../test-50-require-main-parent/test-y-require-B.js')) .concat(require('./sub/test-y-require-C.js')) .concat(require('./sub/test-y-require-C.js')) .concat(require('../test-50-require-main-parent/sub/test-y-require-D.js')) .concat( require('../test-50-require-main-parent/sub/test-y-require-D.js') ) /**/ .join('\n') ); ================================================ FILE: test/test-50-require-main-parent/test-y-require-A.js ================================================ /* eslint-disable no-nested-ternary */ 'use strict'; module.exports = [ __dirname, __filename, typeof module.filename, module.filename ? module.filename : 'empty', typeof module.parent, module.parent ? typeof module.parent.filename : 'empty', module.parent ? module.parent.filename ? module.parent.filename : 'empty' : 'empty', typeof module.require, typeof global, // в nodejs они разные // (module.require === require).toString(), typeof require.main, (require.main === module).toString(), typeof require.main.parent, (require.main.parent || 'null').toString(), require.main.parent ? require.main.parent.id : 'empty', require.main.parent ? require.main.parent.filename : 'empty', typeof global, typeof global.setTimeout, global.module ? (global.module === module).toString() : 'true', global.require ? (global.require === require).toString() : 'true', ]; ================================================ FILE: test/test-50-require-main-parent/test-y-require-B.js ================================================ /* eslint-disable no-nested-ternary */ 'use strict'; module.exports = [ __dirname, __filename, typeof module.filename, module.filename ? module.filename : 'empty', typeof module.parent, module.parent ? typeof module.parent.filename : 'empty', module.parent ? module.parent.filename ? module.parent.filename : 'empty' : 'empty', typeof module.require, typeof global, // в nodejs они разные // (module.require === require).toString(), typeof require.main, (require.main === module).toString(), typeof require.main.parent, (require.main.parent || 'null').toString(), require.main.parent ? require.main.parent.id : 'empty', require.main.parent ? require.main.parent.filename : 'empty', typeof global, typeof global.setTimeout, global.module ? (global.module === module).toString() : 'true', global.require ? (global.require === require).toString() : 'true', ]; ================================================ FILE: test/test-50-require-resolve/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-require-resolve/test-x-index.js ================================================ /* eslint-disable no-multi-spaces */ /* eslint-disable no-useless-concat */ 'use strict'; var fs = require('fs'); var path = require('path'); var theResolve = require.resolve('./test-y-resolve.any'); var theReqCode1 = require('./test-z-require-code-1'); var theReqCode2b = require.resolve('./test-z-require-code-2'); var theReqCode3 = require('./test-z-require-code-3.js'); var theReqCode4b = require.resolve('./test-z-require-code-4.js'); var theReqCode1x = require('./test-z-require-code-1' + ''); var theReqCode2bx = require.resolve('./test-z-require-code-2' + ''); var theReqCode3x = require('./test-z-require-code-3.js' + ''); var theReqCode4bx = require.resolve('./test-z-require-code-4.js' + ''); var theReqContent = fs.readFileSync( path.join(__dirname, './test-z-require-content.css') ); var theReqContentX = fs.readFileSync( path.join(__dirname, './test-z-require-content.css' + '') ); var theReqJson1 = require('./test-z-require-json-1'); var theReqJson2b = require.resolve('./test-z-require-json-2'); var theReqJson3 = require('./test-z-require-json-3.json'); var theReqJson4b = require.resolve('./test-z-require-json-4.json'); var theReqJson1x = require('./test-z-require-json-1' + ''); var theReqJson2bx = require.resolve('./test-z-require-json-2' + ''); var theReqJson3x = require('./test-z-require-json-3.json' + ''); var theReqJson4bx = require.resolve('./test-z-require-json-4.json' + ''); var theReqJson5 = fs.readFileSync( path.join(__dirname, './test-z-require-json-5.json') ); var theReqJson5s = fs.readFileSync( require.resolve(path.join(__dirname, './test-z-require-json-5.json')) ); console.log( [ require(theResolve).what, theReqCode1.what, path.basename(theReqCode2b), theReqCode3.what, path.basename(theReqCode4b), theReqCode1x.what, path.basename(theReqCode2bx), theReqCode3x.what, path.basename(theReqCode4bx), theReqContent.toString().split('\n')[0].split(' ')[0], theReqContentX.toString().split('\n')[0].split(' ')[0], theReqJson1.what, path.basename(theReqJson2b), theReqJson3.what, path.basename(theReqJson4b), theReqJson1x.what, path.basename(theReqJson2bx), theReqJson3x.what, path.basename(theReqJson4bx), theReqJson5.toString().split('"')[3], theReqJson5s.toString().split('"')[3], ].join('\n') ); ================================================ FILE: test/test-50-require-resolve/test-y-resolve.any ================================================ module.exports = { what: "test-y-resolve.any.body" }; ================================================ FILE: test/test-50-require-resolve/test-z-require-code-1.js ================================================ 'use strict'; module.exports = { what: 'test-z-require-code1.js.body', }; ================================================ FILE: test/test-50-require-resolve/test-z-require-code-2.js ================================================ 'use strict'; module.exports = { what: 'test-z-require-code2.js.body', }; ================================================ FILE: test/test-50-require-resolve/test-z-require-code-3.js ================================================ 'use strict'; module.exports = { what: 'test-z-require-code3.js.body', }; ================================================ FILE: test/test-50-require-resolve/test-z-require-code-4.js ================================================ 'use strict'; module.exports = { what: 'test-z-require-code4.js.body', }; ================================================ FILE: test/test-50-require-resolve/test-z-require-content.css ================================================ test-z-require-content.css.body { display: inline-block; position: relative; padding: 0; line-height: normal; margin-right: 0.1em; cursor: pointer; vertical-align: middle; text-align: center; overflow: visible; /* removes extra width in IE */ } .ui-button, .ui-button:link, .ui-button:visited, .ui-button:hover, .ui-button:active { text-decoration: none; } /* to make room for the icon, a width needs to be set here */ .ui-button-icon-only { width: 2.2em; } /* button elements seem to need a little more width */ button.ui-button-icon-only { width: 2.4em; } .ui-button-icons-only { width: 3.4em; } button.ui-button-icons-only { width: 3.7em; } /* button text element */ .ui-button .ui-button-text { display: block; line-height: normal; } .ui-button-text-only .ui-button-text { padding: 0.4em 1em; } .ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: 0.4em; text-indent: -9999999px; } .ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: 0.4em 1em 0.4em 2.1em; } .ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: 0.4em 2.1em 0.4em 1em; } .ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; } ================================================ FILE: test/test-50-require-resolve/test-z-require-json-1.json ================================================ { "what": "test-z-require-json1.json.body" } ================================================ FILE: test/test-50-require-resolve/test-z-require-json-2.json ================================================ { "what": "test-z-require-json2.json.body" } ================================================ FILE: test/test-50-require-resolve/test-z-require-json-3.json ================================================ { "what": "test-z-require-json3.json.body" } ================================================ FILE: test/test-50-require-resolve/test-z-require-json-4.json ================================================ { "what": "test-z-require-json4.json.body" } ================================================ FILE: test/test-50-require-resolve/test-z-require-json-5.json ================================================ { "what": "test-z-require-json5.json.body" } ================================================ FILE: test/test-50-require-resolve-2/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; const output3 = './run-time-3/dummy'; let left, right, right3; utils.mkdirp.sync(path.dirname(output)); utils.mkdirp.sync(path.dirname(output3)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); fs.readdirSync('./').some(function (file) { if (/^test-/.test(file)) { const nf = path.join( path.dirname(file), path.basename(path.dirname(output)), path.basename(file) ); fs.writeFileSync( nf, fs.readFileSync(file, 'utf8').replace('compile-time', 'run-time') ); const nf3 = path.join( path.dirname(file), path.basename(path.dirname(output3)), path.basename(file) ); fs.writeFileSync( nf3, fs.readFileSync(file, 'utf8').replace('compile-time', 'run-time-3') ); } }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); right3 = utils.spawn.sync( './' + path.join('..', path.dirname(output), path.basename(output)), [], { cwd: path.dirname(output3) } ); right = ['require-code-J', 'require-content-K', 'require-content-L'].reduce( function (x, y) { const r = x.replace(new RegExp(y + '-run-time', 'g'), y + '-compile-time'); // assert(r !== x); return r; }, right ); right3 = ['require-code-J'].reduce(function (x, y) { const r = x.replace(new RegExp(y + '-run-time', 'g'), y + '-compile-time'); // assert(r !== x); return r; }, right3); right3 = ['require-content-K', 'require-content-L'].reduce(function (x, y) { const r = x.replace(new RegExp(y + '-run-time-3', 'g'), y + '-compile-time'); // assert(r !== x); return r; }, right3); if (left.length === 0) { left = 'left is empty'; } if (right.length === 0) { right = 'right is empty'; } if (right3.length === 0) { right3 = 'right3 is empty'; } assert.strictEqual(left, right); assert.strictEqual(left, right3); utils.vacuum.sync(path.dirname(output)); utils.vacuum.sync(path.dirname(output3)); ================================================ FILE: test/test-50-require-resolve-2/test-x-index.js ================================================ /* eslint-disable no-multi-spaces */ 'use strict'; var fs = require('fs'); var path = require('path'); /* var theResolveA = require.resolve("./test-y-resolve-A.txt"); var theResolveB = require.resolve("./test-y-resolve-B.txt", "must-exclude"); var theResolveB2 = require.resolve("./test-y-resolve-B.txt", "may-exclude"); var theResolvePathC = "./test-y-resolve-C.txt"; var theResolveC = require.resolve(theResolvePathC); var theResolvePathD = "./test-y-resolve-D.txt"; var theResolveD = require.resolve(theResolvePathD, "must-exclude"); var theResolvePathD2 = "./test-y-resolve-D.txt"; var theResolveD2 = require.resolve(theResolvePathD2, "may-exclude"); var theResolveE = require.resolve("./test-y-resolve-E.txt"); var theResolveF = require.resolve("./test-y-resolve-F.txt", "must-exclude"); var theResolveF2 = require.resolve("./test-y-resolve-F.txt", "may-exclude"); var theResolvePathG = "./test-y-resolve-G.txt"; var theResolveG = require.resolve(theResolvePathG); var theResolvePathH = "./test-y-resolve-H.txt"; var theResolveH = require.resolve(theResolvePathH, "must-exclude"); var theResolvePathH2 = "./test-y-resolve-H.txt"; var theResolveH2 = require.resolve(theResolvePathH2, "may-exclude"); */ var theReqCodeI = require('./test-z-require-code-I.js'); var theReqCodeJ = require('./test-z-require-code-J.js', 'must-exclude'); var theReqCodeJ2 = require('./test-z-require-code-J.js', 'may-exclude'); var theReqContentK = fs.readFileSync('./test-z-require-content-K.txt'); var theReqContentL = fs.readFileSync( './test-z-require-content-L.txt', null, 'must-exclude' ); var theReqContentL2 = fs.readFileSync( './test-z-require-content-L.txt', null, 'may-exclude' ); var theReqContentM = fs.readFileSync( path.join(__dirname, './test-z-require-content-M.txt') ); var theReqContentN = fs.readFileSync( path.join(__dirname, './test-z-require-content-N.txt'), null, 'must-exclude' ); var theReqContentN2 = fs.readFileSync( path.join(__dirname, './test-z-require-content-N.txt'), null, 'may-exclude' ); console.log( [ // fs.readFileSync(theResolveA).toString(), // fs.readFileSync(theResolveB).toString(), // fs.readFileSync(theResolveC).toString(), // fs.readFileSync(theResolveD).toString(), // fs.readFileSync(theResolveE).toString(), // fs.readFileSync(theResolveF, null, "must-exclude").toString(), // fs.readFileSync(theResolveG).toString(), // fs.readFileSync(theResolveH, null, "must-exclude").toString(), theReqCodeI.v, theReqCodeJ.v, theReqCodeJ2.v, theReqContentK.toString(), theReqContentL.toString(), theReqContentL2.toString(), theReqContentM.toString(), theReqContentN.toString(), theReqContentN2.toString(), ].join('\n') ); ================================================ FILE: test/test-50-require-resolve-2/test-y-resolve-A.txt ================================================ test-z-resolve-A-compile-time ================================================ FILE: test/test-50-require-resolve-2/test-y-resolve-B.txt ================================================ test-z-resolve-B-compile-time ================================================ FILE: test/test-50-require-resolve-2/test-y-resolve-C.txt ================================================ test-z-resolve-C-compile-time ================================================ FILE: test/test-50-require-resolve-2/test-y-resolve-D.txt ================================================ test-z-resolve-D-compile-time ================================================ FILE: test/test-50-require-resolve-2/test-y-resolve-E.txt ================================================ test-z-resolve-E-compile-time ================================================ FILE: test/test-50-require-resolve-2/test-y-resolve-F.txt ================================================ test-z-resolve-F-compile-time ================================================ FILE: test/test-50-require-resolve-2/test-y-resolve-G.txt ================================================ test-z-resolve-G-compile-time ================================================ FILE: test/test-50-require-resolve-2/test-y-resolve-H.txt ================================================ test-z-resolve-H-compile-time ================================================ FILE: test/test-50-require-resolve-2/test-z-require-code-I.js ================================================ 'use strict'; module.exports.v = 'test-z-require-code-I-compile-time'; ================================================ FILE: test/test-50-require-resolve-2/test-z-require-code-J.js ================================================ 'use strict'; module.exports.v = 'test-z-require-code-J-compile-time'; ================================================ FILE: test/test-50-require-resolve-2/test-z-require-content-K.txt ================================================ test-z-require-content-K-compile-time ================================================ FILE: test/test-50-require-resolve-2/test-z-require-content-L.txt ================================================ test-z-require-content-L-compile-time ================================================ FILE: test/test-50-require-resolve-2/test-z-require-content-M.txt ================================================ test-z-require-content-M-compile-time ================================================ FILE: test/test-50-require-resolve-2/test-z-require-content-N.txt ================================================ test-z-require-content-N-compile-time ================================================ FILE: test/test-50-require-with-config/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const output = './run-time/test-output.exe'; const output3 = './run-time-3/dummy'; let left, right, right3; utils.mkdirp.sync(path.dirname(output)); utils.mkdirp.sync(path.dirname(output3)); left = utils.spawn.sync('node', ['test-x-index.js']); fs.readdirSync('./').some(function (file) { if (/^test-/.test(file)) { const nf = path.join( path.dirname(file), path.basename(path.dirname(output)), path.basename(file) ); fs.writeFileSync( nf, fs.readFileSync(file, 'utf8').replace('compile-time', 'run-time') ); const nf3 = path.join( path.dirname(file), path.basename(path.dirname(output3)), path.basename(file) ); fs.writeFileSync( nf3, fs.readFileSync(file, 'utf8').replace('compile-time', 'run-time-3') ); } }); utils.pkg.sync(['--target', target, '--output', output, '.']); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); right3 = utils.spawn.sync( './' + path.join('..', path.dirname(output), path.basename(output)), [], { cwd: path.dirname(output3) } ); right = right .replace(/-J-run-time/g, '-J-compile-time') .replace(/-K-run-time/g, '-K-compile-time') .replace(/-L-run-time/g, '-L-compile-time'); right3 = right3 .replace(/-J-run-time-3/g, '-J-compile-time') .replace(/-K-run-time-3/g, '-K-compile-time') .replace(/-L-run-time-3/g, '-L-compile-time'); if (left.length === 0) { left = 'left is empty'; } if (right.length === 0) { right = 'right is empty'; } if (right3.length === 0) { right3 = 'right3 is empty'; } assert.strictEqual(left, right); assert.strictEqual(left, right3); utils.vacuum.sync(path.dirname(output)); utils.vacuum.sync(path.dirname(output3)); ================================================ FILE: test/test-50-require-with-config/package.json ================================================ { "bin": "test-x-index.js", "pkg": { "scripts": "test-z-*.js", "assets": "test-*.txt" } } ================================================ FILE: test/test-50-require-with-config/test-x-index.js ================================================ /* eslint-disable max-statements-per-line */ /* eslint-disable no-multi-spaces */ /* eslint-disable no-useless-concat */ 'use strict'; var fs = require('fs'); var path = require('path'); var theResolveA = require.resolve('./test-y-' + 'resolve-A.txt'); var theResolveB = require.resolve( './test-y-' + 'resolve-B.txt', 'must-exclude' ); var theResolvePathC = './test-y-' + 'resolve-C.txt'; var theResolveC = require.resolve(theResolvePathC); var theResolvePathD = './test-y-' + 'resolve-D.txt'; var theResolveD = require.resolve(theResolvePathD, 'must-exclude'); var theResolveE = require.resolve('./test-y-' + 'resolve-E.txt'); var theResolveF = require.resolve( './test-y-' + 'resolve-F.txt', 'must-exclude' ); var theResolvePathG = './test-y-' + 'resolve-G.txt'; var theResolveG = require.resolve(theResolvePathG); var theResolvePathH = './test-y-' + 'resolve-H.txt'; var theResolveH = require.resolve(theResolvePathH, 'must-exclude'); var theReqCodeI = require('./test-z-' + 'require-code-I.js'); var theReqCodeJ = require(path.resolve('./test-z-' + 'require-code-J')); var theReqContentK = fs.readFileSync('./test-z-' + 'require-content-K.txt'); var theReqContentL = fs.readFileSync( './test-z-' + 'require-content-L.txt', null, 'must-exclude' ); var theReqContentM = fs.readFileSync( path.join(__dirname, './test-z-' + 'require-content-M.txt') ); var theReqContentN = fs.readFileSync( path.join(__dirname, './test-z-' + 'require-content-N.txt'), null, 'must-exclude' ); console.log( [ fs.readFileSync(theResolveA).toString(), fs.readFileSync(theResolveB).toString(), fs.readFileSync(theResolveC).toString(), fs.readFileSync(theResolveD).toString(), fs.readFileSync(theResolveE).toString(), fs.readFileSync(theResolveF, null, 'must-exclude').toString(), fs.readFileSync(theResolveG).toString(), fs.readFileSync(theResolveH, null, 'must-exclude').toString(), theReqCodeI.v, theReqCodeJ.v, theReqContentK.toString(), theReqContentL.toString(), theReqContentM.toString(), theReqContentN.toString(), ].join('\n') ); ================================================ FILE: test/test-50-require-with-config/test-y-resolve-A.txt ================================================ test-z-resolve-A-compile-time ================================================ FILE: test/test-50-require-with-config/test-y-resolve-B.txt ================================================ test-z-resolve-B-compile-time ================================================ FILE: test/test-50-require-with-config/test-y-resolve-C.txt ================================================ test-z-resolve-C-compile-time ================================================ FILE: test/test-50-require-with-config/test-y-resolve-D.txt ================================================ test-z-resolve-D-compile-time ================================================ FILE: test/test-50-require-with-config/test-y-resolve-E.txt ================================================ test-z-resolve-E-compile-time ================================================ FILE: test/test-50-require-with-config/test-y-resolve-F.txt ================================================ test-z-resolve-F-compile-time ================================================ FILE: test/test-50-require-with-config/test-y-resolve-G.txt ================================================ test-z-resolve-G-compile-time ================================================ FILE: test/test-50-require-with-config/test-y-resolve-H.txt ================================================ test-z-resolve-H-compile-time ================================================ FILE: test/test-50-require-with-config/test-z-require-code-I.js ================================================ 'use strict'; module.exports.v = 'test-z-require-code-I-compile-time'; ================================================ FILE: test/test-50-require-with-config/test-z-require-code-J.js ================================================ 'use strict'; module.exports.v = 'test-z-require-code-J-compile-time'; ================================================ FILE: test/test-50-require-with-config/test-z-require-content-K.txt ================================================ test-z-require-content-K-compile-time ================================================ FILE: test/test-50-require-with-config/test-z-require-content-L.txt ================================================ test-z-require-content-L-compile-time ================================================ FILE: test/test-50-require-with-config/test-z-require-content-M.txt ================================================ test-z-require-content-M-compile-time ================================================ FILE: test/test-50-require-with-config/test-z-require-content-N.txt ================================================ test-z-require-content-N-compile-time ================================================ FILE: test/test-50-resolve-and-nearby/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-resolve-and-nearby/test-x-index.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); console.log( [ require('test-y-fish'), // both should have same names fs.readFileSync(path.join(__dirname, 'test-y-fish')), ].join('\n') ); ================================================ FILE: test/test-50-resolve-and-nearby/test-y-fish ================================================ module.exports = "test-y-fish-file"; ================================================ FILE: test/test-50-should-disclose-package/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; const standard = 'stdout'; function rightReducer(mappy, line, index, right) { if ( line.indexOf('Cannot resolve') >= 0 || line.indexOf('The file was included') >= 0 ) { const name = path.basename(right[index + 1]); let value = right[index].split(' as ')[1] || ''; value = value || right[index].split(' Warning ')[1]; if (mappy[name]) assert.strictEqual(mappy[name], value); mappy[name] = value; } return mappy; } for (const pub of [false, true]) { let right; const inspect = standard === 'stdout' ? ['inherit', 'pipe', 'inherit'] : ['inherit', 'inherit', 'pipe']; right = utils.pkg.sync( ['--debug', '--target', target, '--output', output, input].concat( pub ? ['--public'] : [] ), inspect ); assert(right.indexOf('\x1B\x5B') < 0, 'colors detected'); right = right.split('\n'); const mappy = right.reduce(rightReducer, {}); const lines = Object.keys(mappy) .sort() .map(function (key) { return key + ' = ' + mappy[key]; }) .join('\n') + '\n'; assert.strictEqual( lines, 'connect.js = DISCLOSED code (with sources)\n' + 'has-no-license.js = bytecode (no sources)\n' + 'has-permissive-license.js = DISCLOSED code (with sources)\n' + 'has-strict-license.js = bytecode (no sources)\n' + 'package.json = DISCLOSED code (with sources)\n' + (pub ? 'test-x-index.js = DISCLOSED code (with sources)\n' : 'test-x-index.js = bytecode (no sources)\n') ); utils.vacuum.sync(output); } ================================================ FILE: test/test-50-should-disclose-package/test-x-index.js ================================================ 'use strict'; require('connect'); require('has-no-license'); require('has-permissive-license'); require('has-strict-license'); ================================================ FILE: test/test-50-signature/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let right; utils.pkg.sync(['--target', target, '--output', output, input]); let spoiler = fs.readFileSync(output); spoiler = Buffer.concat([ spoiler, Buffer.from([ 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xfe, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xfe, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xfe, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xfe, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xfe, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xfe, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, ]), ]); fs.writeFileSync(output, spoiler); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(right, 'ok\n'); utils.vacuum.sync(output); ================================================ FILE: test/test-50-signature/test-x-index.js ================================================ 'use strict'; console.log('ok'); ================================================ FILE: test/test-50-sigusr1/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const windows = process.platform === 'win32'; const input = './test-x-index.js'; const output = './test-output.exe'; if (windows) return; let right; utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { expect: null }); assert.strictEqual(right, 'ok\n'); utils.vacuum.sync(output); ================================================ FILE: test/test-50-sigusr1/test-x-index.js ================================================ 'use strict'; setTimeout(function () { console.log('ok'); process.kill(process.pid, 'SIGUSR1'); }, 3000); ================================================ FILE: test/test-50-spawn/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const host = 'node' + process.version.match(/^v(\d+)/)[1]; const target = process.argv[2] || host; function rnd() { return Math.random().toString().slice(-6); } const pairs = fs .readdirSync('.') .filter(function (f) { return /\.js$/.test(f) && f !== 'main.js' && !/-child\.js$/.test(f); }) .map(function (f) { return { input: f, output: './test-output-' + rnd() + '.exe', }; }); assert(pairs.length > 6); function stripTraceOpt(lines) { return lines .split('\n') .filter(function (line) { return ( line.indexOf('[disabled optimization') < 0 && line.indexOf('[marking') < 0 && line.indexOf('[compiling method') < 0 && line.indexOf('[optimizing') < 0 && line.indexOf('[completed optimizing') < 0 && line.indexOf('einfo:') < 0 ); }) .join('\n'); } pairs.some(function (pair) { const input = pair.input; const output = pair.output; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); right = stripTraceOpt(right); left = stripTraceOpt(left); if (left !== right) { console.log(JSON.stringify(pair)); console.log('<>right>>\n' + right); throw new Error('Assertion'); } utils.vacuum.sync(output); console.log(__dirname, input, 'ok'); }); ================================================ FILE: test/test-50-spawn/test-cluster-child.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); assert(process.send); assert(cluster.worker); console.log('Hello from cluster-child!'); console.log('Args', JSON.stringify(process.argv.slice(2))); process.on('message', function (value) { if (value === 128) process.exit(); process.send(value * 2); }); ================================================ FILE: test/test-50-spawn/test-cluster.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); var child; if (process.send) { require('./test-cluster-child.js'); return; } assert(cluster.isMaster); try { child = cluster.fork(); } catch (e) { console.log(e.message); } child.on('message', function (value) { console.log(value.toString()); child.send(value); }); child.send(2); cluster.on('exit', function (_, code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-cpfork-a-1.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cp = require('child_process'); var child; assert(!process.send); try { child = cp.fork(require.resolve('./test-cpfork-a-child.js')); } catch (e) { console.log(e.message); } child.on('message', function (value) { console.log(value.toString()); child.send(value); }); child.send(2); child.on('exit', function (code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-cpfork-a-2.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cp = require('child_process'); var child; assert(!process.send); try { child = cp.fork(require.resolve('./test-cpfork-a-child.js'), [ 'argx', '--argvy', ]); } catch (e) { console.log(e.message); } child.on('message', function (value) { console.log(value.toString()); child.send(value); }); child.send(2); child.on('exit', function (code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-cpfork-a-child.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); assert(process.send); assert(!cluster.worker); console.log('Hello from cpfork-a-child!'); console.log('Args', JSON.stringify(process.argv.slice(2))); process.on('message', function (value) { if (value === 128) process.exit(); process.send(value * 2); }); ================================================ FILE: test/test-50-spawn/test-cpfork-b-1.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var path = require('path'); var cp = require('child_process'); var child; assert(!process.send); try { child = cp.fork(path.join(process.cwd(), 'test-cpfork-b-child.js')); } catch (e) { console.log(e.message); } child.on('message', function (value) { console.log(value.toString()); child.send(value); }); child.send(2); child.on('exit', function (code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-cpfork-b-2.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var path = require('path'); var cp = require('child_process'); var child; assert(!process.send); try { child = cp.fork(path.join(process.cwd(), 'test-cpfork-b-child.js'), [ 'argvx', '--argvy', ]); } catch (e) { console.log(e.message); } child.on('message', function (value) { console.log(value.toString()); child.send(value); }); child.send(2); child.on('exit', function (code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-cpfork-b-child.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); assert(process.send); assert(!cluster.worker); console.log('Hello from cpfork-b-child!'); console.log('Args', JSON.stringify(process.argv.slice(2))); process.on('message', function (value) { if (value === 128) process.exit(); process.send(value * 2); }); var fs = require('fs'); try { // must patch fs even if entrypoint is not in snapshot console.log(fs.readFileSync('dirty-hack-for-testing-purposes')); } catch (error) { if (!process.pkg) console.log('dirty-hack-for-testing-purposes'); } ================================================ FILE: test/test-50-spawn/test-exec-1.js ================================================ #!/usr/bin/env node 'use strict'; // AppVeyor: unquoted execPath inside 'Program Files' if (process.platform === 'win32') return; var exec = require('child_process').exec; var child = exec( process.execPath + ' ' + [require.resolve('./test-exec-child.js'), 'argvx', '--argvy'].join(' ') // leave without callback for coverage ); child.stdout.pipe(process.stdout); child.stderr.pipe(process.stderr); child.on('exit', function (code) { setTimeout(function () { console.log('Child exited with code', code); }, 100); }); ================================================ FILE: test/test-50-spawn/test-exec-2.js ================================================ #!/usr/bin/env node 'use strict'; var exec = require('child_process').exec; var child = exec( '"' + process.execPath + '" ' + [require.resolve('./test-exec-child.js'), 'argvx', '--argvy'].join(' '), function (error) { if (error) return console.error(error); console.log('exec done'); } ); child.stdout.pipe(process.stdout); child.stderr.pipe(process.stderr); child.on('exit', function (code) { setTimeout(function () { console.log('Child exited with code', code); }, 100); }); ================================================ FILE: test/test-50-spawn/test-exec-3.js ================================================ #!/usr/bin/env node 'use strict'; var exec = require('child_process').exec; var child = exec( JSON.stringify(process.execPath) + ' ' + [require.resolve('./test-exec-child.js'), 'argvx', '--argvy'].join(' '), function (error) { if (error) return console.error(error); console.log('exec done'); } ); child.stdout.pipe(process.stdout); child.stderr.pipe(process.stderr); child.on('exit', function (code) { setTimeout(function () { console.log('Child exited with code', code); }, 100); }); ================================================ FILE: test/test-50-spawn/test-exec-child.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); assert(!process.send); assert(!cluster.worker); console.log('Hello from exec-child!'); console.log('Args', JSON.stringify(process.argv.slice(2))); ================================================ FILE: test/test-50-spawn/test-execFile-child.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); assert(!process.send); assert(!cluster.worker); console.log('Hello from execFile-child!'); console.log('Args', JSON.stringify(process.argv.slice(2))); ================================================ FILE: test/test-50-spawn/test-execFile.js ================================================ #!/usr/bin/env node 'use strict'; var execFile = require('child_process').execFile; var child = execFile( process.execPath, [require.resolve('./test-execFile-child.js'), 'argvx', '--argvy'], function (error) { if (error) return console.error(error); console.log('execFile done'); } ); child.stdout.pipe(process.stdout); child.stderr.pipe(process.stderr); child.on('exit', function (code) { setTimeout(function () { console.log('Child exited with code', code); }, 100); }); ================================================ FILE: test/test-50-spawn/test-execFileSync-child.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); assert(!process.send); assert(!cluster.worker); console.log('Hello from execFileSync-child!'); console.log('Args', JSON.stringify(process.argv.slice(2))); ================================================ FILE: test/test-50-spawn/test-execFileSync.js ================================================ #!/usr/bin/env node 'use strict'; var execFileSync = require('child_process').execFileSync; execFileSync( process.execPath, [require.resolve('./test-execFileSync-child.js'), 'argvx', '--argvy'], { stdio: 'inherit' } ); ================================================ FILE: test/test-50-spawn/test-execSync-1.js ================================================ #!/usr/bin/env node 'use strict'; // AppVeyor: unquoted execPath inside 'Program Files' if (process.platform === 'win32') return; var execSync = require('child_process').execSync; execSync( process.execPath + ' ' + [require.resolve('./test-execSync-child.js'), 'argvx', '--argvy'].join(' '), { stdio: 'inherit' } ); ================================================ FILE: test/test-50-spawn/test-execSync-2.js ================================================ #!/usr/bin/env node 'use strict'; var execSync = require('child_process').execSync; execSync( '"' + process.execPath + '" ' + [require.resolve('./test-execSync-child.js'), 'argvx', '--argvy'].join(' '), { stdio: 'inherit' } ); ================================================ FILE: test/test-50-spawn/test-execSync-3.js ================================================ #!/usr/bin/env node 'use strict'; var execSync = require('child_process').execSync; execSync( JSON.stringify(process.execPath) + ' ' + [require.resolve('./test-execSync-child.js'), 'argvx', '--argvy'].join(' '), { stdio: 'inherit' } ); ================================================ FILE: test/test-50-spawn/test-execSync-child.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); assert(!process.send); assert(!cluster.worker); console.log('Hello from execSync-child!'); console.log('Args', JSON.stringify(process.argv.slice(2))); ================================================ FILE: test/test-50-spawn/test-node.js ================================================ #!/usr/bin/env node 'use strict'; var spawnSync = require('child_process').spawnSync; var child = spawnSync(process.execPath, ['-e', 'process.stdout.write("42")'], { stdio: 'pipe', // if run under node (process.execPath points to node.exe), // then node ignores PKG_EXECPATH, but if run as pkged app, // PKG_INVOKE_NODEJS is a hack to access internal nodejs env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS' }, }); console.log(child.stdout.toString()); ================================================ FILE: test/test-50-spawn/test-spawn-a-1.js ================================================ #!/usr/bin/env node 'use strict'; var spawn = require('child_process').spawn; if (process.send) { require('./test-spawn-a-child.js'); return; } var child = spawn(process.execPath, [__filename, 'argvx', '--argvy'], { stdio: ['inherit', 'inherit', 'inherit', 'ipc'], }); child.on('message', function (value) { console.log(value.toString()); child.send(value); }); child.send(2); child.on('exit', function (code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-spawn-a-2.js ================================================ #!/usr/bin/env node 'use strict'; var path = require('path'); var spawn = require('child_process').spawn; if (process.send) { require('./test-spawn-a-child.js'); return; } var child = spawn( process.execPath, [path.basename(__filename), 'argvx', '--argvy'], { stdio: ['inherit', 'inherit', 'inherit', 'ipc'] } ); child.on('message', function (value) { console.log(value.toString()); child.send(value); }); child.send(2); child.on('exit', function (code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-spawn-a-3.js ================================================ #!/usr/bin/env node 'use strict'; var spawn = require('child_process').spawn; var child = spawn( process.execPath, [require.resolve('./test-spawn-a-child.js'), 'argvx', '--argvy'], { stdio: ['inherit', 'inherit', 'inherit', 'ipc'] } ); child.on('message', function (value) { console.log(value.toString()); child.send(value); }); child.send(2); child.on('exit', function (code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-spawn-a-4.js ================================================ #!/usr/bin/env node 'use strict'; var spawn = require('child_process').spawn; if (process.send) { require('./test-spawn-a-child.js'); return; } var child = spawn(process.execPath, [process.argv[1], 'argvx', '--argvy'], { stdio: ['inherit', 'inherit', 'inherit', 'ipc'], }); child.on('message', function (value) { console.log(value.toString()); child.send(value); }); child.send(2); child.on('exit', function (code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-spawn-a-5.js ================================================ #!/usr/bin/env node 'use strict'; var path = require('path'); var spawn = require('child_process').spawn; if (process.send) { require('./test-spawn-a-child.js'); return; } var child = spawn( process.argv[0], [path.join(process.cwd(), path.basename(__filename)), 'argvx', '--argvy'], { stdio: ['inherit', 'inherit', 'inherit', 'ipc'] } ); child.on('message', function (value) { console.log(value.toString()); child.send(value); }); child.send(2); child.on('exit', function (code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-spawn-a-child.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); assert(process.send); assert(!cluster.worker); console.log('Hello from spawn-a-child!'); console.log('Args', JSON.stringify(process.argv.slice(2))); process.on('message', function (value) { if (value === 128) process.exit(); process.send(value * 2); }); ================================================ FILE: test/test-50-spawn/test-spawn-b-child.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); assert(process.send); assert(!cluster.worker); console.log('Hello from spawn-b-child!'); console.log('Args', JSON.stringify(process.argv.slice(2))); process.on('message', function (value) { if (value === 128) process.exit(); process.send(value * 2); }); var fs = require('fs'); try { // must patch fs even if entrypoint is not in snapshot console.log(fs.readFileSync('dirty-hack-for-testing-purposes')); } catch (error) { if (!process.pkg) console.log('dirty-hack-for-testing-purposes'); } ================================================ FILE: test/test-50-spawn/test-spawn-b.js ================================================ #!/usr/bin/env node 'use strict'; var path = require('path'); var spawn = require('child_process').spawn; var child = spawn( process.execPath, [path.join(process.cwd(), 'test-spawn-b-child.js'), 'argvx', '--argvy'], { stdio: ['inherit', 'inherit', 'inherit', 'ipc'] } ); child.on('message', function (value) { console.log(value.toString()); child.send(value); }); child.send(2); child.on('exit', function (code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-spawn-c-child.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); assert(!process.send); assert(!cluster.worker); console.log('Hello from spawn-c-child!'); console.log('Args', JSON.stringify(process.argv.slice(2))); ================================================ FILE: test/test-50-spawn/test-spawn-c.js ================================================ #!/usr/bin/env node 'use strict'; if (process.platform !== 'win32') return; var spawn = require('child_process').spawn; var child = spawn( 'cmd.exe', [ '/s', '/c', '"node ' + require.resolve('./test-spawn-c-child.js') + ' argvx argvy"', ], { stdio: 'inherit', windowsVerbatimArguments: true } ); child.on('exit', function (code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-spawn-d-child.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); assert(!process.send); assert(!cluster.worker); console.log('Hello from spawn-d-child!'); console.log('Args', JSON.stringify(process.argv.slice(2))); ================================================ FILE: test/test-50-spawn/test-spawn-d.js ================================================ #!/usr/bin/env node 'use strict'; var pp = process.platform; if (pp !== 'darwin' && pp !== 'linux') return; var spawn = require('child_process').spawn; var child = spawn( '/bin/bash', ['-c', 'node ' + require.resolve('./test-spawn-d-child.js') + ' argvx argvy'], { stdio: 'inherit' } ); child.on('exit', function (code) { console.log('Child exited with code', code); }); ================================================ FILE: test/test-50-spawn/test-spawnSync-child.js ================================================ #!/usr/bin/env node 'use strict'; var assert = require('assert'); var cluster = require('cluster'); assert(!process.send); assert(!cluster.worker); console.log('Hello from spawnSync-child!'); console.log('Args', JSON.stringify(process.argv.slice(2))); ================================================ FILE: test/test-50-spawn/test-spawnSync.js ================================================ #!/usr/bin/env node 'use strict'; var spawnSync = require('child_process').spawnSync; var child = spawnSync( process.execPath, [require.resolve('./test-spawnSync-child.js'), 'argvx', '--argvy'], { stdio: 'inherit' } ); console.log('Child exited with code', child.status); ================================================ FILE: test/test-50-symlink/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); // test symlinks on unix only // TODO junction if (process.platform === 'win32') return; const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; const symlink = './test-symlink.exe'; let right; utils.pkg.sync(['--target', target, '--output', output, input]); fs.symlinkSync(output, symlink); right = utils.spawn.sync('./' + path.basename(symlink), [], { cwd: path.dirname(symlink), }); assert.strictEqual(right, '42\n'); utils.vacuum.sync(output); utils.vacuum.sync(symlink); ================================================ FILE: test/test-50-symlink/test-x-index.js ================================================ 'use strict'; console.log(42); ================================================ FILE: test/test-50-tamper-core/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let left, right; utils.mkdirp.sync(path.dirname(output)); left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-50-tamper-core/test-x-index.js ================================================ 'use strict'; var fsname = 'fs'; var fs = require(fsname); var pathname = 'path'; var pathp = require.resolve(pathname); var path = require(pathp); console.log( [ typeof fs, fs ? typeof fs.statSync : 'empty', typeof path, path ? typeof path.basename : 'empty', ].join('\n') ); ================================================ FILE: test/test-50-undo-patch/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let right; utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), ['./test-y-index.js'], { cwd: path.dirname(output), env: { PKG_EXECPATH: 'PKG_INVOKE_NODEJS' }, }); assert.strictEqual(right, 'ok\n'); utils.vacuum.sync(output); ================================================ FILE: test/test-50-undo-patch/test-x-index.js ================================================ 'use strict'; console.log('should not be executed'); ================================================ FILE: test/test-50-undo-patch/test-y-index.js ================================================ 'use strict'; console.log('ok'); ================================================ FILE: test/test-77-compare-dicts-and-tests/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); let configs = fs.readdirSync('../../dictionary'); configs = configs .filter(function (config) { return config !== '.eslintrc.json'; }) .map(function (config) { assert.strictEqual(config.slice(-3), '.js'); return config.slice(0, -3); }); let tests = fs.readdirSync('../test-79-npm'); tests = tests.filter(function (test) { if (test === '_isolator') return false; const full = path.join('../test-79-npm', test); return fs.statSync(full).isDirectory(); }); tests.push('etc'); // TODO who creates it? tests.push('steam-resources'); // absent in npm. installed via github configs.push('etc'); // TODO who creates it? configs.push('express-with-jade'); configs.push('redis-with-hiredis'); let absent = false; configs.some(function (config) { if (tests.indexOf(config) < 0) { console.log(config + ' is absent in tests'); absent = true; } }); tests.some(function (test) { if (configs.indexOf(test) < 0) { console.log(test + ' is absent in dictionary'); absent = true; } }); assert(!absent); ================================================ FILE: test/test-78-verify-pkg-version/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './test-output.exe'; let left, right; left = require('../../package.json').version; utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(left[0], '5'); assert.strictEqual(right[0], '5'); assert.strictEqual(left + '\n', right); utils.vacuum.sync(output); ================================================ FILE: test/test-78-verify-pkg-version/test-x-index.js ================================================ 'use strict'; console.log(process.versions.pkg); ================================================ FILE: test/test-79-npm/angular-bridge/angular-bridge.js ================================================ 'use strict'; var Bridge = require('angular-bridge'); if (typeof Bridge === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/angular-bridge/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/any-promise/any-promise.js ================================================ 'use strict'; var Promise = require('any-promise'); function p() { return new Promise((resolve) => { resolve('ok'); }); } p().then((result) => { console.log(result); }); ================================================ FILE: test/test-79-npm/any-promise/any-promise.meta.js ================================================ 'use strict'; module.exports = function (stamp) { return { allow: stamp.m >= 46, }; }; ================================================ FILE: test/test-79-npm/any-promise/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/async/async.js ================================================ 'use strict'; var async = require('async'); if (async.waterfall) { console.log('ok'); } ================================================ FILE: test/test-79-npm/async/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/aws-sdk/aws-sdk.js ================================================ 'use strict'; var aws = require('aws-sdk'); var s3 = new aws.S3({ accessKeyId: 'ABRACADABRABRACADABR', secretAccessKey: 'TdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTd', }); s3.listObjects( { Bucket: 'enclosejs', }, function (error) { if (error) { if (error.message.indexOf('does not exist') >= 0) { console.log('ok'); } } } ); ================================================ FILE: test/test-79-npm/aws-sdk/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/babel-core/babel-core.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); var babel = require('babel-core'); var body8 = fs.readFileSync(path.join(__dirname, 'babel-core.txt'), 'utf8'); var code = babel.transform(body8, { ast: false }).code; if (code.length > 20) console.log('ok'); ================================================ FILE: test/test-79-npm/babel-core/babel-core.txt ================================================ let p = process; Object.keys(p).some((key) => { console.log(key); }); ================================================ FILE: test/test-79-npm/babel-core/babel-core@4.7.16.js ================================================ 'use strict'; require('./babel-core.js'); ================================================ FILE: test/test-79-npm/babel-core/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/batch/batch.js ================================================ 'use strict'; var Batch = require('batch'); var batch = new Batch(); batch.concurrency(4); var ids = [4, 7, 12, 25]; ids.forEach(function () { batch.push(function (done) { setTimeout(function () { done(); }, 100); }); }); var passed = 0; batch.on('progress', function () { passed += 1; }); batch.end(function (error) { if (error) { throw error; } if (passed > 3) { console.log('ok'); } }); ================================================ FILE: test/test-79-npm/batch/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/bcrypt/bcrypt.js ================================================ 'use strict'; var bcrypt = require('bcrypt'); var saltRounds = 10; var myPlaintextPassword = 'P4$$w0rD'; bcrypt.genSalt(saltRounds, function (error, salt) { if (error) return; bcrypt.hash(myPlaintextPassword, salt, function (error2, hash) { if (error2) return; if (typeof hash === 'string') { console.log('ok'); } }); }); ================================================ FILE: test/test-79-npm/bcrypt/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/better-sqlite3/.gitignore ================================================ *.sqlite ================================================ FILE: test/test-79-npm/better-sqlite3/better-sqlite3.js ================================================ 'use strict'; const db = require('better-sqlite3')('test-db.sqlite'); db.exec('CREATE TABLE IF NOT EXISTS cats ( name TEXT , age INTEGER )'); const insert = db.prepare('INSERT INTO cats (name, age) VALUES (@name, @age)'); const insertMany = db.transaction((cats) => { for (const cat of cats) insert.run(cat); }); insertMany([ { name: 'Joey', age: 2 }, { name: 'Sally', age: 4 }, { name: 'Junior', age: 1 }, ]); console.log('ok'); ================================================ FILE: test/test-79-npm/better-sqlite3/better-sqlite3.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), }; }; ================================================ FILE: test/test-79-npm/better-sqlite3/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/bignum/bignum.js ================================================ 'use strict'; var bignum = require('bignum'); if (bignum.div) { console.log('ok'); } ================================================ FILE: test/test-79-npm/bignum/bignum.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), note: 'requires C:\\OpenSSL-Win64\\lib\\libeay32.lib', }; }; ================================================ FILE: test/test-79-npm/bignum/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/bindings/bindings.js ================================================ 'use strict'; var bindings = require('bindings'); if (typeof bindings === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/bindings/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/blessed/blessed.js ================================================ 'use strict'; var blessed = require('blessed'); if (typeof blessed === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/blessed/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/body-parser/body-parser.js ================================================ 'use strict'; var parser = require('body-parser'); var req = { headers: {} }; var res = {}; var middleware = parser.json(); middleware(req, res, function () { var middleware2 = parser.urlencoded({ extended: true }); middleware2(req, res, function () { var middleware3 = parser.urlencoded({ extended: false }); middleware3(req, res, function () { console.log('ok'); }); }); }); ================================================ FILE: test/test-79-npm/body-parser/body-parser@1.10.2.js ================================================ 'use strict'; require('./body-parser.js'); ================================================ FILE: test/test-79-npm/body-parser/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/browserify/browserify.js ================================================ 'use strict'; // dont remove --help process.argv.push('--help'); require('browserify/bin/cmd.js'); setTimeout(function () { console.log('ok'); }, 200); ================================================ FILE: test/test-79-npm/browserify/browserify.meta.js ================================================ 'use strict'; module.exports = function () { return { take: 'last-line', }; }; ================================================ FILE: test/test-79-npm/browserify/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/bson/bson.js ================================================ 'use strict'; var bson = require('bson'); var Long = bson.Long; var doc = { long: Long.fromNumber(100) }; var BSON = bson.BSON; var obj = new BSON(); var data = obj.serialize(doc, false, true, false); var doc2 = obj.deserialize(data); if (doc2.long === 100) { console.log('ok'); } ================================================ FILE: test/test-79-npm/bson/bson@0.2.22.js ================================================ 'use strict'; var bson = require('bson'); var pure = {}; pure.Long = bson.pure().Long; pure.doc = { long: pure.Long.fromNumber(100) }; pure.BSON = bson.pure().BSON; pure.obj = new pure.BSON(); pure.data = pure.obj.serialize(pure.doc, false, true, false); pure.doc2 = pure.obj.deserialize(pure.data); var natv = {}; natv.Long = bson.native().Long; natv.doc = { long: natv.Long.fromNumber(200) }; natv.BSON = bson.native().BSON; natv.obj = new natv.BSON(); natv.data = natv.obj.serialize(natv.doc, false, true, false); natv.doc2 = natv.obj.deserialize(natv.data); if (pure.doc2.long === 100) { if (natv.doc2.long === 200) { console.log('ok'); } } ================================================ FILE: test/test-79-npm/bson/bson@0.2.22.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), take: 'last-line', }; }; ================================================ FILE: test/test-79-npm/bson/bson@0.4.0.js ================================================ 'use strict'; require('./bson@0.2.22.js'); ================================================ FILE: test/test-79-npm/bson/bson@0.4.0.meta.js ================================================ 'use strict'; module.exports = require('./bson@0.2.22.meta.js'); ================================================ FILE: test/test-79-npm/bson/bson@1.0.0.js ================================================ 'use strict'; require('./bson.js'); ================================================ FILE: test/test-79-npm/bson/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/buffermaker/buffermaker.js ================================================ 'use strict'; var Buffermaker = require('buffermaker'); var buffermaker = new Buffermaker(); if (buffermaker.plan) { console.log('ok'); } ================================================ FILE: test/test-79-npm/buffermaker/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/bunyan/bunyan.js ================================================ 'use strict'; var bunyan = require('bunyan'); var fs = require('fs'); var logger = bunyan.createLogger({ name: 'pkg', streams: [ { type: 'rotating-file', path: 'pkg.log', level: 'info', }, ], }); if (logger) { fs.unlinkSync('pkg.log'); console.log('ok'); } ================================================ FILE: test/test-79-npm/bunyan/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/busboy/busboy.js ================================================ 'use strict'; var busboy = require('busboy'); if (typeof busboy === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/busboy/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/bytes/bytes.js ================================================ 'use strict'; var bytes = require('bytes'); if (bytes(1024 * 1.7, { decimalPlaces: 0 }) === '2KB') { console.log('ok'); } ================================================ FILE: test/test-79-npm/bytes/bytes@2.5.0.js ================================================ 'use strict'; var bytes = require('bytes'); if (bytes(1024 * 1.7, { decimalPlaces: 0 }) === '2kB') { console.log('ok'); } ================================================ FILE: test/test-79-npm/bytes/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/callsites/callsites.js ================================================ 'use strict'; var path = require('path'); var callsites = require('callsites'); var fns = callsites().map(function (c) { return c.getFileName(); }); if ( fns[1] === 'pkg/prelude/bootstrap.js' || path.basename(fns[0]) === 'callsites.js' ) { console.log('ok'); } ================================================ FILE: test/test-79-npm/callsites/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/checklist.htm ================================================ ================================================ FILE: test/test-79-npm/checklist.js ================================================ /* eslint-disable no-unused-vars */ /* eslint-disable quotes */ 'use strict'; const table = {}; const changes = []; ================================================ FILE: test/test-79-npm/chokidar/chokidar.js ================================================ 'use strict'; var chokidar = require('chokidar'); var watcher = chokidar.watch('./chokidar.js', { persistent: true, }); watcher.on('ready', function () { console.log('ok'); process.exit(); }); ================================================ FILE: test/test-79-npm/chokidar/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/coffee-script/coffee-script-example.coffee ================================================ console.log 'ok' ================================================ FILE: test/test-79-npm/coffee-script/coffee-script.js ================================================ 'use strict'; var path = require('path'); process.argv.push(path.join(__dirname, 'coffee-script-example.coffee')); require('coffee-script/bin/coffee'); ================================================ FILE: test/test-79-npm/coffee-script/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/colors/colors.js ================================================ 'use strict'; var colors = require('colors'); if (typeof colors.green === 'function') { var gopd = Object.getOwnPropertyDescriptor; var grass = gopd(String.prototype, 'green'); if (grass && typeof grass.get === 'function') { console.log('ok'); } } ================================================ FILE: test/test-79-npm/colors/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/compression/compression.js ================================================ 'use strict'; var compression = require('compression'); var req = { headers: {} }; var res = {}; var middleware = compression(); middleware(req, res, function () { console.log('ok'); }); ================================================ FILE: test/test-79-npm/compression/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/compressjs/compressjs.js ================================================ 'use strict'; var compressjs = require('compressjs'); var algorithm = compressjs.Lzp3; if (algorithm.MAGIC === 'lzp3') { console.log('ok'); } ================================================ FILE: test/test-79-npm/compressjs/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/connect/connect.js ================================================ 'use strict'; var connect = require('connect'); if (typeof connect === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/connect/connect@2.3.9.js ================================================ 'use strict'; var connect = require('connect'); var noop = function () {}; var req = { headers: {}, url: '/', originalUrl: '/' }; var res = { setHeader: noop, end: function (s) { if (s.length > 100) { console.log('ok'); process.exit(); } }, }; var middleware = connect.directory.html; middleware( req, res, ['file-name'], function () { console.log('Error not expected'); }, 'directory-name' ); ================================================ FILE: test/test-79-npm/connect/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/connect-mongo/connect-mongo.js ================================================ 'use strict'; function Store() { this.emit = function () {}; } function MemoryStore() {} var session = { Store: Store, MemoryStore: MemoryStore }; var MongoStore = require('connect-mongo')(session); if (typeof MongoStore === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/connect-mongo/connect-mongo.meta.js ================================================ 'use strict'; module.exports = function (stamp) { return { allow: stamp.m >= 46, }; }; ================================================ FILE: test/test-79-npm/connect-mongo/connect-mongo@0.8.2.js ================================================ 'use strict'; require('./connect-mongo.js'); ================================================ FILE: test/test-79-npm/connect-mongo/connect-mongo@0.8.2.meta.js ================================================ 'use strict'; module.exports = require('./connect-mongo.meta.js'); ================================================ FILE: test/test-79-npm/connect-mongo/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/connect-mongodb/connect-mongodb.js ================================================ 'use strict'; var MongoStore = require('connect-mongodb'); if (typeof MongoStore === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/connect-mongodb/connect-mongodb.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), take: 'last-line', }; }; ================================================ FILE: test/test-79-npm/connect-mongodb/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/connect-redis/connect-redis.js ================================================ 'use strict'; function Store() { this.emit = function () {}; } function MemoryStore() {} var session = { Store: Store, MemoryStore: MemoryStore }; var RedisStore = require('connect-redis')(session); if (typeof RedisStore === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/connect-redis/connect-redis.meta.js ================================================ 'use strict'; module.exports = function (stamp) { return { allow: stamp.m >= 46, }; }; ================================================ FILE: test/test-79-npm/connect-redis/connect-redis@2.5.1.js ================================================ 'use strict'; require('./connect-redis.js'); ================================================ FILE: test/test-79-npm/connect-redis/connect-redis@2.5.1.meta.js ================================================ 'use strict'; module.exports = require('./connect-redis.meta.js'); ================================================ FILE: test/test-79-npm/connect-redis/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/consolidate/consolidate.js ================================================ 'use strict'; require('consolidate'); console.log('ok'); ================================================ FILE: test/test-79-npm/consolidate/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/cookie/cookie.js ================================================ 'use strict'; var cookie = require('cookie'); var cookies = cookie.parse('foo=bar; equation=E%3Dmc%5E2'); if (cookies.equation === 'E=mc^2') { console.log('ok'); } ================================================ FILE: test/test-79-npm/cookie/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/cookie-parser/cookie-parser.js ================================================ 'use strict'; var cookieParser = require('cookie-parser'); var req = { headers: { cookie: 'MyCookie=Hello' } }; var res = {}; var middleware = cookieParser(); middleware(req, res, function () { if (req.cookies) { if (req.cookies.MyCookie === 'Hello') { console.log('ok'); } } }); ================================================ FILE: test/test-79-npm/cookie-parser/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/cors/cors.js ================================================ 'use strict'; var cors = require('cors'); var req = { method: 'OPTIONS', headers: {} }; var res = { headers: {}, getHeader: function (name) { return this.headers[name]; }, setHeader: function (name, value) { this.headers[name] = value; }, end: function () { if (res.headers['Access-Control-Allow-Origin'] === '*') { console.log('ok'); } }, }; var middleware = cors(); middleware(req, res); ================================================ FILE: test/test-79-npm/cors/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/cron/cron.js ================================================ 'use strict'; var CronJob = require('cron').CronJob; var counter = 0; new CronJob( // eslint-disable-line no-new '* * * * * *', function () { counter += 1; }, null, true, 'America/Los_Angeles' ); setTimeout(function () { if (counter === 4) console.log('ok'); process.exit(); }, 4500); ================================================ FILE: test/test-79-npm/cron/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/cross-env/cross-env.js ================================================ 'use strict'; require('cross-env'); console.log('ok'); ================================================ FILE: test/test-79-npm/cross-env/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/cross-spawn-async/cross-spawn-async.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); var spawn = require('cross-spawn-async'); var bin = path.join(__dirname, 'fixture.js'); var args = []; if (process.pkg) { args.unshift(bin); bin = process.execPath; } else { fs.chmodSync(bin, 511); } spawn(bin, args, { stdio: 'inherit' }); ================================================ FILE: test/test-79-npm/cross-spawn-async/fixture.js ================================================ #!/usr/bin/env node 'use strict'; console.log('ok'); ================================================ FILE: test/test-79-npm/cross-spawn-async/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/curve25519/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/curve25519/see.hap-nodejs.meta.js ================================================ // hap-nodejs использует git-версию // а та, что в npm даже не компилируется ================================================ FILE: test/test-79-npm/data-preflight/data-preflight.js ================================================ 'use strict'; console.log('ok'); ================================================ FILE: test/test-79-npm/data-preflight/data-preflight.meta.js ================================================ 'use strict'; module.exports = function () { return { allow: false, }; }; ================================================ FILE: test/test-79-npm/data-preflight/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/debug/debug.js ================================================ 'use strict'; var debug = require('debug'); if (typeof debug === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/debug/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/denymount/denymount.js ================================================ 'use strict'; var denymount = require('denymount'); if (typeof denymount === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/denymount/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/diff/diff.js ================================================ 'use strict'; var jsdiff = require('diff'); var one = 'beep boop'; var other = 'beep boob blah'; var diff = jsdiff.diffChars(one, other); var join = ''; diff.forEach(function (part) { var color = 'grey'; if (part.added) color = 'green'; if (part.removed) color = 'red'; join += color + ':[' + part.value + ']'; }); if (join === 'grey:[beep boo]red:[p]green:[b blah]') { console.log('ok'); } ================================================ FILE: test/test-79-npm/diff/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/drivelist/drivelist.js ================================================ 'use strict'; require('./drivelist@3.0.0.js'); ================================================ FILE: test/test-79-npm/drivelist/drivelist.meta.js ================================================ 'use strict'; module.exports = require('./drivelist@3.0.0.meta.js'); ================================================ FILE: test/test-79-npm/drivelist/drivelist@3.0.0.js ================================================ 'use strict'; var drivelist = require('drivelist'); drivelist.list(function (error, list) { if (error) throw error; if (list.length > 0) { console.log('ok'); } }); ================================================ FILE: test/test-79-npm/drivelist/drivelist@3.0.0.meta.js ================================================ 'use strict'; module.exports = function () { return { deployFilesFrom: ['drivelist'], }; }; ================================================ FILE: test/test-79-npm/drivelist/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/ed25519/ed25519.js ================================================ 'use strict'; var ed25519 = require('ed25519'); if (ed25519.MakeKeypair) { console.log('ok'); } ================================================ FILE: test/test-79-npm/ed25519/ed25519.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), note: 'requires C:\\OpenSSL-Win64\\lib\\libeay32.lib', }; }; ================================================ FILE: test/test-79-npm/ed25519/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/ejs/ejs.js ================================================ 'use strict'; var ejs = require('ejs'); var s = '<% if (user) { %>

<%= user.name %>

<% } %>'; var template = ejs.compile(s, { client: true }); var out = template({ user: { name: 'klopov' } }); if (out === '

klopov

') { console.log('ok'); } ================================================ FILE: test/test-79-npm/ejs/ejs@0.8.8.js ================================================ 'use strict'; require('./ejs.js'); ================================================ FILE: test/test-79-npm/ejs/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/elasticsearch/elasticsearch.js ================================================ 'use strict'; require('elasticsearch'); var Log = require('elasticsearch/src/lib/log.js'); var log = new Log({ log: ['warning'] }); log.warning('warning'); console.log('ok'); ================================================ FILE: test/test-79-npm/elasticsearch/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/electron/electron.js ================================================ 'use strict'; // see nightmare require('electron'); console.log('ok'); ================================================ FILE: test/test-79-npm/electron/electron.meta.js ================================================ 'use strict'; module.exports = function () { return { deployFilesFrom: ['electron'], }; }; ================================================ FILE: test/test-79-npm/electron/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/emailjs/emailjs.js ================================================ 'use strict'; var emailjs = require('emailjs'); if (typeof emailjs.server.connect === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/emailjs/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/engine.io/engine.io.js ================================================ 'use strict'; var http = require('http'); var engine = require('engine.io'); engine.listen(3000); setTimeout(function () { http.get('http://127.0.0.1:3000/socket.io/socket.io.js', function (res) { var chunks = ''; res .on('data', function (chunk) { chunks += chunk.toString(); }) .on('end', function () { if (chunks === 'Not Implemented') { console.log('ok'); } process.exit(); }); }); }, 100); ================================================ FILE: test/test-79-npm/engine.io/engine.io@1.8.0.js ================================================ 'use strict'; require('./engine.io.js'); ================================================ FILE: test/test-79-npm/engine.io/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/epoll/epoll.js ================================================ 'use strict'; var Epoll = require('epoll').Epoll; if (Epoll.EPOLLPRI) { console.log('ok'); } ================================================ FILE: test/test-79-npm/epoll/epoll.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp) && stamp.p === 'linux', note: 'only linux is supported', }; }; ================================================ FILE: test/test-79-npm/epoll/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/errorhandler/errorhandler.js ================================================ 'use strict'; var errorhandler = require('errorhandler'); var noop = function () {}; var req = { headers: { Accept: 'text/html' } }; var res = { setHeader: noop, end: noop }; var middleware = errorhandler(); var wasCalled = false; middleware('Message', req, res, function () { wasCalled = true; }); setTimeout(function () { if (!wasCalled) console.log('ok'); }, 200); ================================================ FILE: test/test-79-npm/errorhandler/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/errors/errors.js ================================================ 'use strict'; require('errors'); console.log('ok'); ================================================ FILE: test/test-79-npm/errors/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/eslint/eslint.js ================================================ 'use strict'; require('eslint/bin/eslint.js'); console.log('ok'); ================================================ FILE: test/test-79-npm/eslint/eslint.meta.js ================================================ 'use strict'; module.exports = function () { return { take: 'last-line', }; }; ================================================ FILE: test/test-79-npm/eslint/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/etcher-image-write/etcher-image-write.js ================================================ 'use strict'; var writer = require('etcher-image-write'); if (writer.write) { console.log('ok'); } ================================================ FILE: test/test-79-npm/etcher-image-write/etcher-image-write.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp) && stamp.m >= 48, }; }; ================================================ FILE: test/test-79-npm/etcher-image-write/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/exceljs/exceljs.js ================================================ 'use strict'; var Excel = require('exceljs'); var workbook = new Excel.Workbook(); if (workbook.created) { console.log('ok'); } ================================================ FILE: test/test-79-npm/exceljs/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/exiftool.pl/exiftool.pl.js ================================================ 'use strict'; var fs = require('fs'); var exiftool = require('exiftool.pl'); if (fs.existsSync(exiftool)) { console.log('ok'); } else { console.log('Unable to open file:', exiftool); } ================================================ FILE: test/test-79-npm/exiftool.pl/exiftool.pl.meta.js ================================================ 'use strict'; module.exports = function () { return { deployFilesFrom: ['exiftool.pl'], }; }; ================================================ FILE: test/test-79-npm/exiftool.pl/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/express/express.js ================================================ 'use strict'; var express = require('express'); if (typeof express === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/express/express@3.5.3.js ================================================ 'use strict'; require('./express.js'); ================================================ FILE: test/test-79-npm/express/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/express-load/controllers/fixture.js ================================================ 'use strict'; module.exports.index = function (req, res, next) { res.send('Hello world!'); if (next) return next(); }; ================================================ FILE: test/test-79-npm/express-load/express-load.config.json ================================================ { "bin": "express-load.js", "pkg": { "scripts": ["controllers/*.js", "routes/*.js"] } } ================================================ FILE: test/test-79-npm/express-load/express-load.js ================================================ 'use strict'; var load = require('express-load'); var app = {}; app.get = function () {}; app.index = 'Welcome!'; var opts = {}; // opts.verbose = true; load('controllers', opts).then('routes').into(app); if (app.controllers.fixture && app.routes.fixture) { console.log('ok'); } ================================================ FILE: test/test-79-npm/express-load/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/express-load/routes/fixture.js ================================================ 'use strict'; module.exports = function (app) { return app.controllers.fixture.index; }; ================================================ FILE: test/test-79-npm/express-session/express-session.js ================================================ 'use strict'; var session = require('express-session'); var req = { url: '/', headers: {} }; var res = {}; function genuuid() { return 'SESSIONID'; } var middleware = session({ genid: function () { return genuuid(); }, resave: false, saveUninitialized: false, secret: 'keyboard cat', }); middleware(req, res, function () { if (req.sessionID === 'SESSIONID') { console.log('ok'); } }); ================================================ FILE: test/test-79-npm/express-session/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/express-with-jade/express.config.json ================================================ { "bin": "express.js", "dependencies": { "jade": "*" }, "pkg": { "assets": ["views/*.jade"] } } ================================================ FILE: test/test-79-npm/express-with-jade/express.js ================================================ 'use strict'; var http = require('http'); var express = require('express'); var app = express(); app.set('views', 'views'); app.set('view engine', 'jade'); app.get('/', function (req, res) { res.render('fixture.jade', { title: 'Hey', message: 'Hello there!' }); }); var server = app.listen(1337, function () { var port = server.address().port; setTimeout(function () { http.get('http://127.0.0.1:' + port.toString() + '/', function (res) { var chunks = ''; res .on('data', function (chunk) { chunks += chunk.toString(); }) .on('end', function () { if ( chunks === 'Hey' + '

Hello there!

' ) { console.log('ok'); } server.close(); }); }); }, 100); }); ================================================ FILE: test/test-79-npm/express-with-jade/express.meta.js ================================================ 'use strict'; module.exports = function () { return { packages: ['jade'], }; }; ================================================ FILE: test/test-79-npm/express-with-jade/express@3.0.6.config.json ================================================ { "bin": "express@3.0.6.js", "dependencies": { "jade": "*" }, "pkg": { "assets": ["views/*.jade"] } } ================================================ FILE: test/test-79-npm/express-with-jade/express@3.0.6.js ================================================ 'use strict'; require('./express.js'); ================================================ FILE: test/test-79-npm/express-with-jade/express@3.0.6.meta.js ================================================ 'use strict'; module.exports = require('./express.meta.js'); ================================================ FILE: test/test-79-npm/express-with-jade/express@3.21.2.config.json ================================================ { "bin": "express@3.21.2.js", "dependencies": { "jade": "*" }, "pkg": { "assets": ["views/*.jade"] } } ================================================ FILE: test/test-79-npm/express-with-jade/express@3.21.2.js ================================================ 'use strict'; require('./express.js'); ================================================ FILE: test/test-79-npm/express-with-jade/express@3.21.2.meta.js ================================================ 'use strict'; module.exports = require('./express.meta.js'); ================================================ FILE: test/test-79-npm/express-with-jade/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/express-with-jade/views/fixture.jade ================================================ html head title!= title body h1!= message ================================================ FILE: test/test-79-npm/extender/extender.js ================================================ 'use strict'; var extender = require('extender'); var e = extender.define({ multiply: function (str, times) { var ret = str; for (var i = 1; i < times; i += 1) { ret += str; } return ret; }, }); var v = e('hello').multiply(2).value(); if (v === 'hellohello') { console.log('ok'); } ================================================ FILE: test/test-79-npm/extender/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/extsprintf/extsprintf.js ================================================ 'use strict'; var sprintf = require('extsprintf').sprintf; if (typeof sprintf === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/extsprintf/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/faye-websocket/faye-websocket.js ================================================ 'use strict'; var websocket = require('faye-websocket'); if (websocket.Client) { console.log('ok'); } ================================================ FILE: test/test-79-npm/faye-websocket/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/feathers/feathers.js ================================================ 'use strict'; var feathers = require('feathers'); var http = require('http'); var app = feathers(); app.get('/', function (req, res) { res.end('Hello there!'); }); var server = app.listen(1337, function () { var port = server.address().port; setTimeout(function () { http.get('http://127.0.0.1:' + port.toString() + '/', function (res) { var chunks = ''; res .on('data', function (chunk) { chunks += chunk.toString(); }) .on('end', function () { if (chunks === 'Hello there!') { console.log('ok'); } server.close(); }); }); }, 100); }); ================================================ FILE: test/test-79-npm/feathers/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/findup-sync/findup-sync.js ================================================ 'use strict'; var findup = require('findup-sync'); var pj = findup('package.json'); console.log(pj ? 'ok' : 'bad'); ================================================ FILE: test/test-79-npm/findup-sync/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/floordate/floordate.js ================================================ 'use strict'; var floordate = require('floordate'); var d = new Date(); var v = floordate(d, 'year').getFullYear(); if (v > 2015 && v < 2075) { console.log('ok'); } ================================================ FILE: test/test-79-npm/floordate/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/fmt/fmt.js ================================================ 'use strict'; var fmt = require('fmt'); var save; console.log = function (s) { save = s; }; fmt.sep(); if (save.slice(0, 3) === '===') { process.stdout.write('ok\n'); } ================================================ FILE: test/test-79-npm/fmt/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/formidable/formidable.js ================================================ 'use strict'; require('formidable'); console.log('ok'); ================================================ FILE: test/test-79-npm/formidable/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/fs-extra/fs-extra.js ================================================ 'use strict'; // only pkg-ed run if (!process.pkg) { console.log('ok'); return; } var fs = require('fs-extra'); var hack = 'dirty-hack-for-testing-purposes'; if (fs.readFileSync(hack) === hack) { console.log('ok'); } ================================================ FILE: test/test-79-npm/fs-extra/fs-extra@0.20.1.js ================================================ 'use strict'; require('./fs-extra.js'); ================================================ FILE: test/test-79-npm/fs-extra/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/fsevents/fsevents.js ================================================ 'use strict'; var fsevents = require('fsevents'); if (typeof fsevents === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/fsevents/fsevents.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp) && stamp.p === 'darwin', note: 'only macos is supported', }; }; ================================================ FILE: test/test-79-npm/fsevents/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/geoip-lite/geoip-lite.js ================================================ 'use strict'; var geoip = require('geoip-lite'); var ip = '207.97.227.239'; var geo = geoip.lookup(ip); if (geo.country === 'US') { console.log('ok'); } ================================================ FILE: test/test-79-npm/geoip-lite/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/github/github.js ================================================ 'use strict'; var GitHubApi = require('github'); var github = new GitHubApi(); github.users.getForUser( { username: 'igorklopov', }, function (error, res) { if (error) return; if (res.data.name === 'Igor Klopov') { console.log('ok'); } } ); ================================================ FILE: test/test-79-npm/github/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/gm/gm.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); var gm = require('gm').subClass({ imageMagick: true }); var input = path.join(__dirname, 'piechart.png'); var inputStream = fs.createReadStream(input); var output = 'piechart-resize.png'; gm(inputStream) .resize(240, 240) .write(output, function (error) { if (error) throw error; if (fs.existsSync(output)) { fs.unlinkSync(output); console.log('ok'); } }); ================================================ FILE: test/test-79-npm/gm/gm.meta.js ================================================ 'use strict'; module.exports = function () { return { note: 'requires GraphicsMagick/ImageMagick installed', }; }; ================================================ FILE: test/test-79-npm/gm/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/google-closure-compiler/google-closure-compiler.js ================================================ 'use strict'; var fs = require('fs'); var Compiler = require('google-closure-compiler').compiler; if ( fs.existsSync(Compiler.JAR_PATH) && Compiler.JAR_PATH.indexOf('snapshot') < 0 ) { console.log('ok'); } ================================================ FILE: test/test-79-npm/google-closure-compiler/google-closure-compiler.meta.js ================================================ 'use strict'; module.exports = function () { return { deployFilesFrom: ['google-closure-compiler-java'], }; }; ================================================ FILE: test/test-79-npm/google-closure-compiler/google-closure-compiler@20180610.0.2.js ================================================ 'use strict'; var fs = require('fs'); var Compiler = require('google-closure-compiler').compiler; if ( fs.existsSync(Compiler.JAR_PATH) && Compiler.JAR_PATH.indexOf('snapshot') < 0 ) { console.log('ok'); } ================================================ FILE: test/test-79-npm/google-closure-compiler/google-closure-compiler@20180610.0.2.meta.js ================================================ 'use strict'; module.exports = function () { return { deployFilesFrom: ['google-closure-compiler'], }; }; ================================================ FILE: test/test-79-npm/google-closure-compiler/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/google-closure-compiler-java/google-closure-compiler-java.js ================================================ 'use strict'; var pathToCompiler = require('google-closure-compiler-java'); if (pathToCompiler.indexOf('snapshot') < 0) { console.log('ok'); } ================================================ FILE: test/test-79-npm/google-closure-compiler-java/google-closure-compiler-java.meta.js ================================================ 'use strict'; module.exports = function () { return { deployFilesFrom: ['google-closure-compiler-java'], }; }; ================================================ FILE: test/test-79-npm/google-closure-compiler-java/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/googleapis/googleapis.js ================================================ 'use strict'; var google = require('googleapis'); var urlshortener = google.urlshortener('v1'); if (urlshortener.url) { console.log('ok'); } ================================================ FILE: test/test-79-npm/googleapis/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/got/got.js ================================================ 'use strict'; var got = require('got'); if (typeof got === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/got/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/graceful-fs/graceful-fs.js ================================================ 'use strict'; // only pkg-ed run if (!process.pkg) { console.log('ok'); return; } var fs = require('graceful-fs'); var hack = 'dirty-hack-for-testing-purposes'; if (fs.readFileSync(hack) === hack) { console.log('ok'); } ================================================ FILE: test/test-79-npm/graceful-fs/graceful-fs@3.0.8.js ================================================ 'use strict'; require('./graceful-fs.js'); ================================================ FILE: test/test-79-npm/graceful-fs/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/grpc/grpc.js ================================================ 'use strict'; var grpc = require('grpc'); if (grpc.status) { console.log('ok'); } ================================================ FILE: test/test-79-npm/grpc/grpc.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), note: 'seems not compatible with freebsd network headers', }; }; ================================================ FILE: test/test-79-npm/grpc/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/gulp/gulp-concat-01.txt ================================================ 123 ================================================ FILE: test/test-79-npm/gulp/gulp-concat-02.txt ================================================ 456 ================================================ FILE: test/test-79-npm/gulp/gulp.js ================================================ /* eslint-disable no-path-concat */ 'use strict'; var path = require('path'); process.env.NODE_PATH = (process.env.NODE_PATH || '') .split(path.delimiter) .filter((p) => p) .concat(__dirname + '/node_modules') .join(path.delimiter); require('module')._initPaths(); // eslint-disable-line no-underscore-dangle require('gulp'); require('gulp-concat'); require('gulp/bin/gulp.js'); ================================================ FILE: test/test-79-npm/gulp/gulp.meta.js ================================================ 'use strict'; module.exports = function () { return { packages: ['gulp-concat'], deployFiles: ['gulp-concat-01.txt', 'gulp-concat-02.txt', 'gulpfile.js'], take: 'last-line', }; }; ================================================ FILE: test/test-79-npm/gulp/gulpfile.js ================================================ /* eslint-disable no-underscore-dangle */ 'use strict'; var gulp = require('gulp'); var concat = require('gulp-concat'); gulp.task('default', function () { gulp .src('gulp-concat-*.txt') .pipe(concat('gulp-concat-out.txt', { newLine: '' })) .on('data', function (c) { if (c._contents.toString() === '123456') { (console._log_ || console.log)('ok'); } }); }); ================================================ FILE: test/test-79-npm/gulp/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/hap-nodejs/hap-nodejs.js ================================================ 'use strict'; var hap = require('hap-nodejs'); if (hap.Service) { console.log('ok'); } ================================================ FILE: test/test-79-npm/hap-nodejs/hap-nodejs.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp, flags) { if (flags.ci) { return { allow: false, note: 'headless CI seems to fail', }; } return { allow: home(stamp), note: 'requires OpenSSL-dev and mdns installed', }; }; ================================================ FILE: test/test-79-npm/hap-nodejs/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/heapdump/heapdump.js ================================================ 'use strict'; var fs = require('fs'); var heapdump = require('heapdump'); var name = './heapdump.heapsnapshot'; heapdump.writeSnapshot(name, function (error1, filename) { if (error1) throw error1; fs.unlink(filename, function (error2) { if (error2) throw error2; console.log('ok'); }); }); ================================================ FILE: test/test-79-npm/heapdump/heapdump.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), }; }; // TODO windows has an error // 'Invalid access to memory location' ================================================ FILE: test/test-79-npm/heapdump/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/hoek/hoek.js ================================================ 'use strict'; var hoek = require('hoek'); if (typeof hoek.applyToDefaults === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/hoek/hoek.meta.js ================================================ 'use strict'; module.exports = function (stamp) { return { allow: stamp.m >= 46, }; }; ================================================ FILE: test/test-79-npm/hoek/hoek@0.9.1.js ================================================ 'use strict'; require('./hoek.js'); ================================================ FILE: test/test-79-npm/hoek/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/home.js ================================================ 'use strict'; const o = require('./stamp.js'); module.exports = function (stamp) { return o.p === stamp.p && o.a === stamp.a && o.m === stamp.m; }; ================================================ FILE: test/test-79-npm/homebridge/homebridge.js ================================================ 'use strict'; process.argv.push('--help'); require('homebridge/lib/cli.js'); // dont run. only load var Server = require('homebridge/lib/server.js').Server; var server = new Server(); // eslint-disable-next-line no-underscore-dangle if (server._api) { console.log('ok'); } ================================================ FILE: test/test-79-npm/homebridge/homebridge.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp, flags) { if (flags.ci) { return { allow: false, note: 'headless CI seems to fail', }; } return { allow: home(stamp), note: 'requires OpenSSL-dev and mdns installed', }; }; ================================================ FILE: test/test-79-npm/homebridge/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/http-proxy/http-proxy.js ================================================ 'use strict'; require('http-proxy'); console.log('ok'); ================================================ FILE: test/test-79-npm/http-proxy/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/http-server/http-server.js ================================================ 'use strict'; var http = require('http'); process.argv.push('--silent'); require('http-server/bin/http-server'); setTimeout(function () { http.get('http://127.0.0.1:8080/package.json', function (res) { if (res.statusCode) { console.log('ok'); process.exit(); } }); }, 5000); ================================================ FILE: test/test-79-npm/http-server/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/image-size/image-size.js ================================================ 'use strict'; var path = require('path'); var sizeOf = require('image-size'); var dimensions = sizeOf(path.join(__dirname, 'viewbox.svg')); if (dimensions.width === 123) { console.log('ok'); } ================================================ FILE: test/test-79-npm/image-size/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/indexof/indexof.js ================================================ 'use strict'; var indexof = require('indexof'); if (indexof([3, 4, 5, 6], 4) === 1) { console.log('ok'); } ================================================ FILE: test/test-79-npm/indexof/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/inquirer/inquirer.js ================================================ 'use strict'; var inquirer = require('inquirer'); if (inquirer.prompt) { console.log('ok'); } ================================================ FILE: test/test-79-npm/inquirer/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/j/j.js ================================================ 'use strict'; var j = require('j'); var path = require('path'); var xls = j.readFile(path.join(__dirname, 'registry.xls')); if (xls[1].Strings.length > 50) { console.log('ok'); } ================================================ FILE: test/test-79-npm/j/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/jade/jade.js ================================================ 'use strict'; // see also express.js var file = 'html\n' + ' head\n' + ' title!= title\n' + ' body\n' + ' h1!= message\n'; var jade = require('jade'); var fn = jade.compile(file, {}); var html = fn({ title: 'Hey', message: 'Hello there!' }); if ( html === 'Hey' + '

Hello there!

' ) { console.log('ok'); } ================================================ FILE: test/test-79-npm/jade/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/jsdom/jsdom.js ================================================ 'use strict'; var JSDOM = require('jsdom').JSDOM; var dom = new JSDOM( '

jsdom!

' ); var window = dom.window; if (window.document.body.children[0].tagName === 'P') { console.log('ok'); } ================================================ FILE: test/test-79-npm/jsdom/jsdom.meta.js ================================================ 'use strict'; module.exports = function (stamp) { return { allow: stamp.m >= 46, }; }; ================================================ FILE: test/test-79-npm/jsdom/jsdom@8.5.0.js ================================================ 'use strict'; var jsdom = require('jsdom'); jsdom.env( '

jsdom!

', function (errors, window) { if (window.document.body.children[0].tagName === 'P') { console.log('ok'); } } ); ================================================ FILE: test/test-79-npm/jsdom/jsdom@8.5.0.meta.js ================================================ 'use strict'; module.exports = require('./jsdom.meta.js'); ================================================ FILE: test/test-79-npm/jsdom/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/json-stringify-date/json-stringify-date.js ================================================ 'use strict'; var stringify = require('json-stringify-date'); var obj = { d: new Date(2014, 2, 4) }; var s = stringify.stringify(obj); if (s.indexOf('2014') >= 0) { console.log('ok'); } ================================================ FILE: test/test-79-npm/json-stringify-date/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/json-stringify-safe/json-stringify-safe.js ================================================ 'use strict'; var stringify = require('json-stringify-safe'); var circularObj = {}; circularObj.circularRef = circularObj; circularObj.list = [circularObj, circularObj]; console.error(stringify(circularObj, null, 2)); console.log('ok'); ================================================ FILE: test/test-79-npm/json-stringify-safe/json-stringify-safe@4.0.0.js ================================================ 'use strict'; require('./json-stringify-safe.js'); ================================================ FILE: test/test-79-npm/json-stringify-safe/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/jsonwebtoken/jsonwebtoken.js ================================================ 'use strict'; var jwt = require('jsonwebtoken'); var token = jwt.sign({ foo: 'bar' }, 'shhhhh'); if (token.length > 10) { console.log('ok'); } ================================================ FILE: test/test-79-npm/jsonwebtoken/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/kerberos/kerberos.js ================================================ 'use strict'; function isModuleNotFoundError(error) { return ( error.code === 'MODULE_NOT_FOUND' && error.message.indexOf('build/Release/kerberos') >= 0 ); } var kerberos; function hideTryBlockFromBundleDetectorIgnoreFlag() { kerberos = require('kerberos'); } try { hideTryBlockFromBundleDetectorIgnoreFlag(); } catch (error) { if (!isModuleNotFoundError(error)) { console.log('bad1', error); return; } } var sspi; function hideTryBlockFromBundleDetectorIgnoreFlag2() { sspi = require('kerberos/lib/sspi'); } try { if (process.platform === 'win32') { hideTryBlockFromBundleDetectorIgnoreFlag2(); } } catch (error) { if (!isModuleNotFoundError(error)) { console.log('bad2', error); return; } } if (kerberos) { if (typeof kerberos.Kerberos !== 'function') { console.log('bad'); return; } } if (sspi) { if (typeof sspi.SSPI !== 'function') { console.log('bad'); return; } } console.log('ok'); ================================================ FILE: test/test-79-npm/kerberos/kerberos.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), }; }; ================================================ FILE: test/test-79-npm/kerberos/kerberos@0.0.10.js ================================================ 'use strict'; require('./kerberos.js'); ================================================ FILE: test/test-79-npm/kerberos/kerberos@0.0.10.meta.js ================================================ 'use strict'; module.exports = require('./kerberos.meta.js'); ================================================ FILE: test/test-79-npm/kerberos/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/knex/knex.js ================================================ 'use strict'; var knex = require('knex'); if (knex) { console.log('ok'); } ================================================ FILE: test/test-79-npm/knex/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/later/later.js ================================================ 'use strict'; var later = require('later'); if (later.schedule) { console.log('ok'); } ================================================ FILE: test/test-79-npm/later/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/level/level.js ================================================ 'use strict'; var level = require('level'); var db = level('dbname'); var rimraf = require('../../../node_modules/rimraf'); (function (cb) { db.open(function (error1) { if (error1) return cb(error1); db.put( 'dave@gmail.com', JSON.stringify({ _id: 'dave@gmail.com', name: 'David', age: 68, }), function (error2) { if (error2) return cb(error2); db.get('dave@gmail.com', function (error3, data) { if (error3) return cb(error3); data = JSON.parse(data.toString()); if (data.age === 68) { console.log('ok'); return cb(); } }); } ); }); })(function (error) { if (error) throw error; db.close(function () { rimraf.sync('dbname'); }); }); ================================================ FILE: test/test-79-npm/level/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/leveldown/leveldown.js ================================================ 'use strict'; var Leveldown = require('leveldown'); var db = new Leveldown('dbname'); var rimraf = require('../../../node_modules/rimraf'); (function (cb) { db.open(function (error1) { if (error1) return cb(error1); db.put( 'dave@gmail.com', JSON.stringify({ _id: 'dave@gmail.com', name: 'David', age: 68, }), function (error2) { if (error2) return cb(error2); db.get('dave@gmail.com', function (error3, data) { if (error3) return cb(error3); data = JSON.parse(data.toString()); if (data.age === 68) { console.log('ok'); return cb(); } }); } ); }); })(function (error) { if (error) throw error; db.close(function () { rimraf.sync('dbname'); }); }); ================================================ FILE: test/test-79-npm/leveldown/leveldown.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), deployFilesFrom: ['leveldown'], }; }; ================================================ FILE: test/test-79-npm/leveldown/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/levelup/levelup.js ================================================ 'use strict'; var Levelup = require('levelup'); var db = new Levelup('dbname'); var rimraf = require('../../../node_modules/rimraf'); (function (cb) { db.open(function (error1) { if (error1) return cb(error1); db.put( 'dave@gmail.com', JSON.stringify({ _id: 'dave@gmail.com', name: 'David', age: 68, }), function (error2) { if (error2) return cb(error2); db.get('dave@gmail.com', function (error3, data) { if (error3) return cb(error3); data = JSON.parse(data.toString()); if (data.age === 68) { console.log('ok'); return cb(); } }); } ); }); })(function (error) { if (error) throw error; db.close(function () { rimraf.sync('dbname'); }); }); ================================================ FILE: test/test-79-npm/levelup/levelup.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), packages: ['leveldown@1'], }; }; ================================================ FILE: test/test-79-npm/levelup/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/liftoff/liftoff.js ================================================ 'use strict'; var liftoff = require('liftoff'); if (typeof liftoff === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/liftoff/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/lodash/lodash.js ================================================ 'use strict'; var lodash = require('lodash'); if (typeof lodash === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/lodash/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/log4js/log4js.js ================================================ 'use strict'; var log4js = require('log4js'); var logger = log4js.getLogger('cheese'); if (logger.log) { console.log('ok'); } ================================================ FILE: test/test-79-npm/log4js/log4js@0.5.8.js ================================================ 'use strict'; var log4js = require('log4js'); log4js.loadAppender('file'); var logger = log4js.getLogger('cheese'); logger.setLevel('ERROR'); console.log('ok'); ================================================ FILE: test/test-79-npm/log4js/log4js@0.6.34.js ================================================ 'use strict'; require('./log4js@0.5.8.js'); ================================================ FILE: test/test-79-npm/log4js/log4js@1.1.1.js ================================================ 'use strict'; require('./log4js@0.5.8.js'); ================================================ FILE: test/test-79-npm/log4js/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/logform/logform.js ================================================ 'use strict'; var logform = require('logform'); var format = logform.format; if (format.combine()) { console.log('ok'); } ================================================ FILE: test/test-79-npm/logform/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/machinepack-urls/machinepack-urls.js ================================================ 'use strict'; var mu = require('machinepack-urls'); var b = mu.parse; if (typeof b === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/machinepack-urls/machinepack-urls@5.0.0.js ================================================ 'use strict'; var mu = require('machinepack-urls'); var b = mu.validate; if (typeof b === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/machinepack-urls/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/main.js ================================================ #!/usr/bin/env node /* eslint-disable complexity */ 'use strict'; // note: you can set the env variable USE_PREINSTALLED_MODULES to prevent reconstruction // of the npm cache folder. const UPM = process.env.USE_PREINSTALLED_MODULES || false; // USE_PREINSTALLED_MODULES const fs = require('fs'); const path = require('path'); const assert = require('assert'); const globby = require('globby'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const hostVersion = process.version.match(/^v(\d+)/)[1]; const host = 'node' + hostVersion; const target = process.argv[2] || host; const windows = process.platform === 'win32'; const npm = { 8: 5, 10: 5, 12: 6, 14: 6, 16: 7, 18: 8, }[hostVersion]; assert(npm !== undefined); function applyMetaToRight(right, meta) { right = meta.take === 'stderr' ? right.stderr : right.stdout; if (meta.take === 'last-line') right = right.split('\n').slice(-2).join('\n'); if (right.slice(-2) === '\r\n') right = right.slice(0, -2); if (right.slice(-1) === '\n') right = right.slice(0, -1); return right; } let stamp = {}; const checklist = fs.readFileSync('checklist.js', 'utf-8'); let table = checklist.split('const table = ')[1].split(';')[0]; table = JSON.parse(table); let changes = checklist.split('const changes = ')[1].split(';')[0]; changes = JSON.parse(changes); function save() { const t = utils.stringify(table, undefined, 2); let c = utils.stringify(changes, undefined, 2); if (c === '[]') c = '[\n]'; fs.writeFileSync( 'checklist.js', '/* eslint-disable no-unused-vars */\n' + '/* eslint-disable quotes */\n' + '\n' + "'use strict';\n" + '\n' + 'const table = ' + t + ';\n' + 'const changes = ' + c + ';\n' ); } function stamp2string(s) { // platform, arch, modules return s.p + '/' + s.a + '/m' + s.m.toString(); } function update(p, r, v, note) { if (!table[p]) table[p] = {}; const row = table[p]; const ss = stamp2string(stamp); const o = row[ss]; const rv = r + (v ? ',' + v : ''); const rn = r + (note ? ',' + note : ''); row[ss] = rv + (note ? ',' + note : ''); const o2 = o ? o.split(',')[0] : undefined; if (!o && r !== 'ok') { changes.push(p + ',' + ss + ': new ' + rn); } else if (o2 !== undefined && o2 !== r) { changes.push(p + ',' + ss + ': ' + o + ' -> ' + rn); } save(); } if (!UPM) { console.log('Cleaning cache...'); if (windows) { utils.vacuum.sync(path.join(process.env.APPDATA, 'npm-cache')); utils.mkdirp.sync(path.join(process.env.APPDATA, 'npm-cache')); } else { if (npm >= 5) { utils.exec.sync('npm cache clean --force'); } else { utils.exec.sync('npm cache clean'); } } utils.mkdirp.sync('_isolator'); } (function () { console.log('Getting stamp...'); const input = path.resolve('stamp.js'); const lucky = path.basename(input).slice(0, -3); const output = path.resolve('_isolator', lucky + '.exe'); utils.pkg.sync(['--target', target, '--output', output, input]); stamp = utils.spawn.sync(output); stamp = JSON.parse(stamp); utils.vacuum.sync(output); console.log('Stamp is ' + JSON.stringify(stamp)); utils.pause(2); })(); // note to developpers: // you can set the env variable FILTER to something like "better-sqlite3/*.js" // to restrict this test to this single test case const inputs = globby .sync([ process.env.FILTER || './*/*.js', '!./*/*.config.js', '!./*/*.meta.js', '!./*/gulpfile.js', '!./*/*fixture*', ]) .map(function (result) { return path.resolve(result); }); let times = {}; const ci = process.env.CI; if (ci) { console.log('Getting latest times...'); const foldyNames = inputs.map(function (input) { const foldy = path.dirname(input); const foldyName = path.basename(foldy); return foldyName; }); times = JSON.parse(utils.exec.sync('node times.js ' + foldyNames.join())); } inputs.some(function (input) { const foldy = path.dirname(input); const foldyName = path.basename(foldy); const packy = path.basename(input).slice(0, -3); const packyName = packy.split('@')[0]; const packyWildcard = packy.split('@')[1]; let wordy = packy; if (packyName !== foldyName) { wordy = foldyName + '/' + wordy; } const output = path.resolve('_isolator', packy + '.exe'); console.log(); console.log('*********************************************************'); console.log('*********************************************************'); console.log('*********************************************************'); console.log('Testing ' + wordy + '...'); if (ci) { const latestTime = times[foldyName]; if (latestTime) { const diff = Date.now() - latestTime; const days = (diff / 1000 / 60 / 60 / 24) | 0; if (days >= 360) { // no need to pollute changes with this // update(wordy, 'nop', '', 'abandoned'); console.log('Last published ' + days + ' days ago!'); return; } } } const flags = { ci }; let metajs = path.join(foldy, packy + '.meta.js'); metajs = fs.existsSync(metajs) ? require(metajs) : undefined; let meta; if (metajs) { meta = metajs(stamp, flags) || {}; } else { meta = {}; } let allow; if (typeof meta.allow !== 'undefined') { allow = meta.allow; } else { allow = true; } const note = meta.note; if (!allow) { update(wordy, 'nop', '', note); console.log('Not allowed here!'); if (note) console.log('Note:', note); return; } let version = ''; if (!UPM) { const build = meta.build; const packages = [packy].concat(meta.packages || []); console.log('Installing ' + packages + '...'); let successful = false; let counter = 10; while (!successful && counter > 0) { successful = true; let command = 'npm install ' + packages.join(' '); if (npm >= 5) command += ' --no-save'; if (build) command += ' --build-from-source=' + build; command += ' --unsafe-perm'; try { utils.exec.sync(command, { cwd: foldy }); } catch (__) { assert(__); utils.vacuum.sync(path.join(foldy, 'node_modules')); successful = false; counter -= 1; } } let packyVersion; try { packyVersion = JSON.parse( fs.readFileSync( path.join(foldy, 'node_modules', packy.split('@')[0], 'package.json'), 'utf8' ) ).version; } catch (___) { update(wordy, 'bad-npm-i', '', note); console.log(wordy + ' failed to install here!'); if (note) console.log('Note:', note); return; } console.log('Version of ' + packy + ' is ' + packyVersion); version = packyVersion; if (packyWildcard) { assert.strictEqual(packyWildcard.split('.').length, 3); assert.strictEqual(packyVersion, packyWildcard); } } let right; console.log('Running non-compiled ' + wordy + '...'); try { right = utils.spawn.sync('node', [input], { cwd: path.dirname(input), stdio: 'pipe', }); } catch (___) { right = { stdout: '', stderr: ___.toString(), }; } right = applyMetaToRight(right, meta); console.log("Result is '" + right + "'"); if (right !== 'ok') { update(wordy, 'bad-test', version, note); } else { console.log('Compiling ' + wordy + '...'); const config = path.join(foldy, packy + '.config.json'); if (fs.existsSync(config)) { const bin = JSON.parse(fs.readFileSync(config)).bin; assert.strictEqual(path.join(foldy, bin), input); input = config; } utils.pkg.sync(['--target', target, '--output', output, input]); console.log('Copying addons...'); const deployFiles = []; if (!meta.deployFiles && !meta.deployFilesFrom) { globby .sync(path.join(foldy, 'node_modules', '**', '*.node')) .some(function (deployFrom) { deployFiles.push([ deployFrom, path.join(path.dirname(output), path.basename(deployFrom)), ]); }); } const deployFilesRelative = []; if (meta.deployFiles) { meta.deployFiles.some(function (deployFile) { deployFilesRelative.push(deployFile); }); } if (meta.deployFilesFrom) { meta.deployFilesFrom.some(function (dictName) { const dict = require('../../dictionary/' + dictName); dict.pkg.deployFiles.some(function (deployFile) { const deployFrom = 'node_modules/' + dictName + '/' + deployFile[0]; const deployTo = deployFile[1]; deployFilesRelative.push([deployFrom, deployTo]); }); }); } deployFilesRelative.some(function (deployFile) { let deployFrom; let deployTo; if (Array.isArray(deployFile)) { deployFrom = deployFile[0]; deployTo = deployFile[1]; } else { deployFrom = deployFile; deployTo = deployFile; } // whole directory supported, glob not assert(deployFrom.indexOf('*') < 0); assert(deployTo.indexOf('*') < 0); deployFrom = path.join(foldy, deployFrom); deployTo = path.join(path.dirname(output), deployTo); if (fs.existsSync(deployFrom)) { const statFrom = fs.statSync(deployFrom); if (statFrom.isFile()) { deployFiles.push([deployFrom, deployTo]); } else { globby .sync(path.join(deployFrom, '**', '*')) .some(function (deployFrom2) { const r = path.relative(deployFrom, deployFrom2); const deployTo2 = path.join(deployTo, r); if (fs.existsSync(deployFrom2)) { const statFrom2 = fs.statSync(deployFrom2); if (statFrom2.isFile()) { deployFiles.push([deployFrom2, deployTo2]); } } }); } } }); deployFiles.some(function (deployFile) { const deployFrom = deployFile[0]; const deployTo = deployFile[1]; const statFrom = fs.statSync(deployFrom); utils.mkdirp.sync(path.dirname(deployTo)); fs.writeFileSync(deployTo, fs.readFileSync(deployFrom)); fs.chmodSync(deployTo, statFrom.mode.toString(8).slice(-3)); }); console.log('Running compiled ' + wordy + '...'); try { right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), stdio: 'pipe', }); } catch (___) { right = { stdout: '', stderr: ___.toString(), }; } right = applyMetaToRight(right, meta); console.log("Result is '" + right + "'"); if (right !== 'ok') { update(wordy, 'error', version, note); } else { update(wordy, 'ok', version); } } const rubbishes = globby.sync(path.join(path.dirname(output), '**', '*')); rubbishes.some(function (rubbish) { utils.vacuum.sync(rubbish); }); if (!UPM) { console.log('Cleanup...'); utils.vacuum.sync(path.join(foldy, 'node_modules')); } }); console.log('\nChanges:\n' + changes.join('\n') + '\n'); ================================================ FILE: test/test-79-npm/markdown/markdown.js ================================================ 'use strict'; var markdown = require('markdown').markdown; var html = markdown.toHTML('Hello *World*!'); if (html === '

Hello World!

') { console.log('ok'); } ================================================ FILE: test/test-79-npm/markdown/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/mdns/mdns.js ================================================ 'use strict'; var mdns = require('mdns'); if (mdns.dns_sd) { console.log('ok'); } ================================================ FILE: test/test-79-npm/mdns/mdns.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), note: 'requires mdns installed', }; }; ================================================ FILE: test/test-79-npm/mdns/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/method-override/method-override.js ================================================ 'use strict'; var override = require('method-override'); var req = { method: 'GET', headers: {} }; var res = {}; var middleware = override(); middleware(req, res, function () { if (req.originalMethod === 'GET') { console.log('ok'); } }); ================================================ FILE: test/test-79-npm/method-override/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/microjob/microjob.js ================================================ 'use strict'; var start = require('microjob').start; if (typeof start === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/microjob/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/mime/mime.js ================================================ 'use strict'; var mime = require('mime'); if (mime.getType('html') === 'text/html') { console.log('ok'); } ================================================ FILE: test/test-79-npm/mime/mime@1.4.1.js ================================================ 'use strict'; var mime = require('mime'); if (mime.lookup('html') === 'text/html') { console.log('ok'); } ================================================ FILE: test/test-79-npm/mime/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/mime-types/mime-types.js ================================================ 'use strict'; var mime = require('mime-types'); if (mime.lookup('html') === 'text/html') { console.log('ok'); } ================================================ FILE: test/test-79-npm/mime-types/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/minimatch/minimatch.js ================================================ 'use strict'; var minimatch = require('minimatch'); if (minimatch('bar.foo', '*.foo') && !minimatch('bar.foo', '*.bar')) { console.log('ok'); } ================================================ FILE: test/test-79-npm/minimatch/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/minstache/minstache.js ================================================ 'use strict'; var minstache = require('minstache'); if (typeof minstache === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/minstache/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/module-deps/module-deps.js ================================================ 'use strict'; var Deps = require('module-deps'); var deps = new Deps(); if (deps.parseDeps) { console.log('ok'); } ================================================ FILE: test/test-79-npm/module-deps/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/moment/moment.js ================================================ 'use strict'; var moment = require('moment'); moment.locale('ru'); var newyear = new Date(2014, 0, 1); var s = moment(newyear).format('llll'); if (s.indexOf('янв') >= 0) { console.log('ok'); } ================================================ FILE: test/test-79-npm/moment/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/moment-timezone/moment-timezone.js ================================================ 'use strict'; var moment = require('moment-timezone'); var june = moment('2014-06-01T12:00:00Z'); var s = june.tz('America/Los_Angeles').format('ha z'); if (s === '5am PDT') { console.log('ok'); } ================================================ FILE: test/test-79-npm/moment-timezone/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/mongodb/mongodb.js ================================================ 'use strict'; var mongodb = require('mongodb'); var MongoClient = mongodb.MongoClient; if (typeof MongoClient === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/mongodb/mongodb.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), }; }; ================================================ FILE: test/test-79-npm/mongodb/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/mongodb-core/mongodb-core.js ================================================ 'use strict'; var Server = require('mongodb-core').Server; if (typeof Server === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/mongodb-core/mongodb-core@1.0.5.js ================================================ 'use strict'; require('./mongodb-core.js'); ================================================ FILE: test/test-79-npm/mongodb-core/mongodb-core@1.0.5.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), take: 'last-line', }; }; ================================================ FILE: test/test-79-npm/mongodb-core/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/mongoose/mongoose.js ================================================ 'use strict'; var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/pkg-test'); var Cat = mongoose.model('Cat', { name: String }); var name = 'Tuz' + new Date().getTime().toString(); var kitty = new Cat({ name: name }); kitty.save(function (error1) { if (error1) return; Cat.find({}) .$where(function () { return this.name.slice(0, 3) === 'Tuz'; }) .exec(function (error2, cats) { if (process.pkg) { if (cats) return; if (error2.message.indexOf('Pkg') >= 0) { console.log('ok'); mongoose.disconnect(); } } else { if (error2) return; if (cats.length > 0) { console.log('ok'); mongoose.disconnect(); } } }); }); ================================================ FILE: test/test-79-npm/mongoose/mongoose.meta.js ================================================ 'use strict'; module.exports = function () { return { allow: false, // TODO fix hanging and enable // stamp.p !== 'win32', note: 'requires MongoDB installed', }; }; ================================================ FILE: test/test-79-npm/mongoose/mongoose@3.9.7.js ================================================ 'use strict'; require('./mongoose.js'); ================================================ FILE: test/test-79-npm/mongoose/mongoose@3.9.7.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp) && stamp.p !== 'win32' && stamp.m <= 46, note: 'requires MongoDB installed\n' + ' ...also require("mongodb/node_modules/bson") does not work in flat npm', }; }; ================================================ FILE: test/test-79-npm/mongoose/mongoose@4.0.8.js ================================================ 'use strict'; require('./mongoose.js'); ================================================ FILE: test/test-79-npm/mongoose/mongoose@4.0.8.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp) && stamp.p !== 'win32', note: 'requires MongoDB installed', }; }; ================================================ FILE: test/test-79-npm/mongoose/mongoose@4.1.12.js ================================================ 'use strict'; require('./mongoose.js'); ================================================ FILE: test/test-79-npm/mongoose/mongoose@4.1.12.meta.js ================================================ 'use strict'; module.exports = require('./mongoose@4.0.8.meta.js'); ================================================ FILE: test/test-79-npm/mongoose/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/mongoskin/mongoskin@2.0.3.js ================================================ 'use strict'; require('mongoskin'); console.log('ok'); ================================================ FILE: test/test-79-npm/mongoskin/mongoskin@2.0.3.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), packages: ['mongodb@2.0'], }; }; ================================================ FILE: test/test-79-npm/mongoskin/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/ms/ms.js ================================================ 'use strict'; var ms = require('ms'); if (ms('15m') === 900000) { console.log('ok'); } ================================================ FILE: test/test-79-npm/ms/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/msgpack/msgpack.js ================================================ 'use strict'; var msgpack = require('msgpack'); var o = { a: 1, b: 2, c: [1, 2, 3] }; var b = msgpack.pack(o); var oo = msgpack.unpack(b); if (JSON.stringify(o) === JSON.stringify(oo)) { console.log('ok'); } ================================================ FILE: test/test-79-npm/msgpack/msgpack.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), }; }; ================================================ FILE: test/test-79-npm/msgpack/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/multer/multer.js ================================================ 'use strict'; var multer = require('multer'); if (typeof multer === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/multer/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/muri/muri.js ================================================ 'use strict'; var muri = require('muri'); // console.log(muri.version); var o = muri( 'mongodb://user:pass@local,remote:27018,japan:27019/neatdb?replicaSet=myreplset&journal=true&w=2&wtimeoutMS=50' ); if (o.options.replicaSet === 'myreplset') { console.log('ok'); } ================================================ FILE: test/test-79-npm/muri/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/native-or-bluebird/native-or-bluebird.js ================================================ 'use strict'; var Promise = require('native-or-bluebird'); if (Promise && global.Promise) { console.log('ok'); } ================================================ FILE: test/test-79-npm/native-or-bluebird/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/natives/natives.js ================================================ 'use strict'; var natives = require('natives'); var fsCopy = natives.require('fs'); if (fsCopy !== require('fs')) { console.log('ok'); } ================================================ FILE: test/test-79-npm/natives/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/nconf/nconf.js ================================================ 'use strict'; var nconf = require('nconf'); nconf.argv(); var foo = nconf.get('foo'); if (typeof foo === 'undefined') { console.log('ok'); } ================================================ FILE: test/test-79-npm/nconf/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/nedb/nedb.js ================================================ 'use strict'; var Nedb = require('nedb'); var fs = require('fs'); var filename = 'database.db'; var db = new Nedb({ filename: filename }); db.loadDatabase(function (error) { if (error) throw error; db.insert([{ a: 5 }, { a: 42 }], function (error2) { if (error2) throw error2; fs.unlinkSync(filename); console.log('ok'); }); }); ================================================ FILE: test/test-79-npm/nedb/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/negotiator/negotiator.js ================================================ 'use strict'; var Negotiator = require('negotiator'); var availableMediaTypes = ['text/html', 'text/plain', 'application/json']; var request = { headers: {} }; var negotiator = new Negotiator(request); var mt1 = negotiator.mediaTypes(); var mt2 = negotiator.mediaTypes(availableMediaTypes); var mt3 = negotiator.mediaType(availableMediaTypes); if (mt1.join('+') !== '*/*') return; if (mt2.join('+') !== 'text/html+text/plain+application/json') return; if (mt3 !== 'text/html') return; console.log('ok'); ================================================ FILE: test/test-79-npm/negotiator/negotiator@0.4.9.js ================================================ 'use strict'; require('./negotiator.js'); ================================================ FILE: test/test-79-npm/negotiator/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/newrelic/newrelic.js ================================================ 'use strict'; var fs = require('fs'); process.env.NEW_RELIC_APP_NAME = 'pkg-test'; process.env.NEW_RELIC_NO_CONFIG_FILE = true; var Agent = require('newrelic/lib/agent.js'); Agent.prototype.start = function () { console.log('ok'); fs.unlinkSync('newrelic_agent.log'); process.exit(); }; require('newrelic'); ================================================ FILE: test/test-79-npm/newrelic/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/nib/nib.js ================================================ 'use strict'; var nib = require('nib'); if (typeof nib.version === 'string') { console.log('ok'); } ================================================ FILE: test/test-79-npm/nib/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/nightmare/nightmare.config.json ================================================ { "bin": "nightmare.js", "pkg": { "assets": ["nightmare.js"] } } ================================================ FILE: test/test-79-npm/nightmare/nightmare.js ================================================ 'use strict'; var Nightmare = require('nightmare'); var nightmare = new Nightmare({ show: false }); nightmare .goto('http://yahoo.com') .type('form[action*="/search"] [name=p]', 'github nightmare') .click('form[action*="/search"] [type=submit]') .wait('#main') .evaluate(function () { // nightmare takes thisFunction.toString(), so --public // is needed (or placing this file to assets) return document.querySelector('#main .searchCenterMiddle li a').href; }) .end() .then(function (result) { if (result.indexOf('segmentio') >= 0) console.log('ok'); }); ================================================ FILE: test/test-79-npm/nightmare/nightmare.meta.js ================================================ 'use strict'; module.exports = function (stamp, flags) { if (flags.ci) { return { allow: false, note: 'headless CI seems to fail headful electron', }; } return { deployFilesFrom: ['electron', 'nightmare'], }; }; ================================================ FILE: test/test-79-npm/nightmare/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/node-forge/node-forge.js ================================================ 'use strict'; var forge = require('node-forge'); if (typeof forge.tls.createConnection === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/node-forge/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/node-libcurl/node-libcurl.js ================================================ 'use strict'; // apt-get install libcurl4-openssl-dev // IF YOU USE 32-BIT NODEJS: // patch /usr/include/curl/curlbuild.h // #define CURL_SIZEOF_LONG 4 // #define CURL_SIZEOF_CURL_OFF_T 4 var Curl = require('node-libcurl').Curl; var curl = new Curl(); curl.setOpt('URL', 'www.yandex.ru'); curl.setOpt('FOLLOWLOCATION', true); curl.on('end', function (status) { if (status === 200) { console.log('ok'); } this.close(); // eslint-disable-line no-invalid-this }); curl.perform(); ================================================ FILE: test/test-79-npm/node-libcurl/node-libcurl.meta.js ================================================ 'use strict'; // in win32 must manually // "git clone curl-for-windows" // in debian there is a bug // in /usr/include/curl/curlbuild.h module.exports = function () { return { allow: false, note: 'hard to meet various requirements', }; }; ================================================ FILE: test/test-79-npm/node-libcurl/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/node-notifier/node-notifier.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); var notifier = require('node-notifier'); var utils = require('node-notifier/lib/utils.js'); var whichArgument; utils.command = utils.fileCommandJson = utils.immediateFileCommand = function (filename) { var forLinux = filename === whichArgument; // 'notify-send' is built-in on linux var forNonLinux = fs.existsSync(filename) && path.isAbsolute(filename); if ((forLinux || forNonLinux) && filename.indexOf('snapshot') < 0) { console.log('ok'); } process.exit(); }; var which = require('which'); which.sync = function (filename) { whichArgument = filename; return true; }; notifier.notify('hi!'); ================================================ FILE: test/test-79-npm/node-notifier/node-notifier.meta.js ================================================ 'use strict'; module.exports = function (stamp, flags) { if (stamp.p === 'win32' && flags.ci) { return { allow: false, note: 'headless windows CI seems to fail to show baloon', }; } if (stamp.p === 'win32' && stamp.m < 48) { return { allow: false, note: "flat npm is needed to require('which')", }; } return { deployFilesFrom: ['node-notifier'], }; }; ================================================ FILE: test/test-79-npm/node-notifier/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/node-pre-gyp/node-pre-gyp.js ================================================ 'use strict'; var fs = require('fs'); if (!fs.existsSync('package.json')) { fs.writeFileSync('package.json', '{}'); } var Run = require('node-pre-gyp').Run; var r = new Run(); try { r.commands.clean(); } catch (e) { if ( e.message.indexOf('undefined package.json is not node-pre-gyp ready') >= 0 ) { console.log('ok'); } } ================================================ FILE: test/test-79-npm/node-pre-gyp/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/node-redis-pubsub/node-redis-pubsub.js ================================================ 'use strict'; var NRP = require('node-redis-pubsub'); var config = { port: 6379, scope: 'demo' }; new NRP(config); // eslint-disable-line no-new process.on('uncaughtException', function (error) { var ok = error.code === 'ECONNREFUSED'; if (ok) console.log('ok'); process.exit(); }); ================================================ FILE: test/test-79-npm/node-redis-pubsub/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/node-sass/node-sass.js ================================================ 'use strict'; var sass = require('node-sass'); var data = '#hello {\n color: #08c; }\n'; const result = sass.renderSync({ data: data }).css.toString(); if (result === data) { console.log('ok'); } ================================================ FILE: test/test-79-npm/node-sass/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/node-uuid/node-uuid.js ================================================ 'use strict'; var uuid = require('node-uuid'); if (uuid.v1().length === 36) { console.log('ok'); } ================================================ FILE: test/test-79-npm/node-uuid/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/node-xlsx/node-xlsx.js ================================================ 'use strict'; var path = require('path'); var xlsx = require('node-xlsx'); var xls = xlsx.parse(path.join(__dirname, 'registry.xls')); var ods = xlsx.parse(path.join(__dirname, 'ffc.ods')); var data = [ [1, 2, 3], [true, false, null, 'sheetjs'], ['foo', 'bar', new Date('2014-02-19T14:30Z'), '0.3'], ['baz', null, 'qux'], ]; var buffer = xlsx.build([{ name: 'SheetName', data: data }]); if (xls[0].data.length > 50 && ods[0].data.length > 30 && buffer.length > 10) { console.log('ok'); } ================================================ FILE: test/test-79-npm/node-xlsx/node-xlsx.meta.js ================================================ 'use strict'; module.exports = function (stamp) { return { allow: stamp.m >= 46, }; }; ================================================ FILE: test/test-79-npm/node-xlsx/node-xlsx@0.6.0.js ================================================ 'use strict'; require('./node-xlsx.js'); ================================================ FILE: test/test-79-npm/node-xlsx/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/node-zookeeper-client/node-zookeeper-client.js ================================================ 'use strict'; var zookeeper = require('node-zookeeper-client'); var client = zookeeper.createClient('localhost:2181'); if (client.state) { console.log('ok'); } ================================================ FILE: test/test-79-npm/node-zookeeper-client/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/nodegit/nodegit.js ================================================ 'use strict'; var NodeGit = require('nodegit'); var Diff = NodeGit.Diff; NodeGit.Repository.init('./', 0) .then(function (repo) { return Diff.indexToWorkdir(repo, null, { flags: Diff.OPTION.INCLUDE_UNTRACKED | Diff.OPTION.RECURSE_UNTRACKED_DIRS, }); }) .then(function () { console.log('ok'); }); ================================================ FILE: test/test-79-npm/nodegit/nodegit.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp) && stamp.m === 51, // TODO check node8 some day note: 'precompiled binary is for node7 only', }; }; ================================================ FILE: test/test-79-npm/nodegit/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/nodemailer/nodemailer.js ================================================ 'use strict'; var nodemailer = require('nodemailer'); var transporter = nodemailer.createTransport( 'smtps://user%40gmail.com:pass@smtp.gmail.com' ); if (transporter.transporter) { console.log('ok'); } ================================================ FILE: test/test-79-npm/nodemailer/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/nodemailer-sendmail-transport/nodemailer-sendmail-transport.js ================================================ 'use strict'; require('nodemailer-sendmail-transport'); console.log('ok'); ================================================ FILE: test/test-79-npm/nodemailer-sendmail-transport/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/npm/npm.meta.js ================================================ 'use strict'; module.exports = function () { return { allow: false, }; }; ================================================ FILE: test/test-79-npm/npm/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/npm-registry-client/npm-registry-client.js ================================================ 'use strict'; var RegistryClient = require('npm-registry-client'); var client = new RegistryClient({}); if (typeof client.whoami === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/npm-registry-client/npm-registry-client@6.0.7.js ================================================ 'use strict'; require('./npm-registry-client.js'); ================================================ FILE: test/test-79-npm/npm-registry-client/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/nssocket/nssocket.js ================================================ 'use strict'; var nssocket = require('nssocket'); if (nssocket.createServer) { console.log('ok'); } ================================================ FILE: test/test-79-npm/nssocket/nssocket@0.5.3.js ================================================ 'use strict'; require('./nssocket.js'); ================================================ FILE: test/test-79-npm/nssocket/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/oauth2orize/oauth2orize.js ================================================ 'use strict'; require('oauth2orize'); console.log('ok'); ================================================ FILE: test/test-79-npm/oauth2orize/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/octobat/octobat.js ================================================ 'use strict'; var octobat = require('octobat'); if (octobat.DEFAULT_HOST === 'api.octobat.com') { console.log('ok'); } ================================================ FILE: test/test-79-npm/octobat/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/open/open.js ================================================ 'use strict'; var open = require('open'); open('package.json').then(() => { console.log('ok'); }); ================================================ FILE: test/test-79-npm/open/open.meta.js ================================================ 'use strict'; module.exports = function (stamp, flags) { if (stamp.p === 'win32' && flags.ci) { return { allow: false, note: 'headless windows CI seems to fail', }; } return { deployFilesFrom: ['open'], }; }; ================================================ FILE: test/test-79-npm/open/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/opn/opn.js ================================================ 'use strict'; var opn = require('opn'); opn('package.json').then(() => { console.log('ok'); }); ================================================ FILE: test/test-79-npm/opn/opn.meta.js ================================================ 'use strict'; module.exports = function (stamp, flags) { if (stamp.p === 'win32' && flags.ci) { return { allow: false, note: 'headless windows CI seems to fail', }; } return { deployFilesFrom: ['opn'], }; }; ================================================ FILE: test/test-79-npm/opn/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/optimist/optimist.js ================================================ 'use strict'; var optimist = require('optimist'); var argv = optimist.argv; if (argv.$0) { console.log('ok'); } ================================================ FILE: test/test-79-npm/optimist/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/passport/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/passport/passport.js ================================================ 'use strict'; var passport = require('passport'); if (passport.Strategy) { console.log('ok'); } ================================================ FILE: test/test-79-npm/passport/passport@0.2.2.js ================================================ 'use strict'; require('./passport.js'); ================================================ FILE: test/test-79-npm/passport-local/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/passport-local/passport-local.js ================================================ 'use strict'; var passport = require('passport-local'); if (passport.Strategy) { console.log('ok'); } ================================================ FILE: test/test-79-npm/passport-local/passport-local@0.1.6.js ================================================ 'use strict'; require('./passport-local.js'); ================================================ FILE: test/test-79-npm/pg/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/pg/pg.js ================================================ 'use strict'; var pg = require('pg'); if (pg.Connection) { console.log('ok'); } ================================================ FILE: test/test-79-npm/pg/pg@3.6.3.js ================================================ 'use strict'; var pg = require('pg'); if (pg.connect) { console.log('ok'); } ================================================ FILE: test/test-79-npm/pg/pg@4.0.0.js ================================================ 'use strict'; require('./pg@3.6.3.js'); ================================================ FILE: test/test-79-npm/pg/pg@6.4.1.js ================================================ 'use strict'; require('./pg@3.6.3.js'); ================================================ FILE: test/test-79-npm/pg-cursor/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/pg-cursor/pg-cursor.js ================================================ 'use strict'; var Cursor = require('pg-cursor'); var cursor = new Cursor('SELECT * FROM some_table WHERE prop > $1', [100]); if (cursor.state) { console.log('ok'); } ================================================ FILE: test/test-79-npm/pg-cursor/pg-cursor.meta.js ================================================ 'use strict'; module.exports = function () { return { packages: ['pg'], }; }; ================================================ FILE: test/test-79-npm/pg-query-stream/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/pg-query-stream/pg-query-stream.js ================================================ 'use strict'; require('./pg-query-stream@1.0.0.js'); ================================================ FILE: test/test-79-npm/pg-query-stream/pg-query-stream.meta.js ================================================ 'use strict'; module.exports = require('./pg-query-stream@1.0.0.meta.js'); ================================================ FILE: test/test-79-npm/pg-query-stream/pg-query-stream@1.0.0.js ================================================ 'use strict'; var QueryStream = require('pg-query-stream'); var query = new QueryStream('SELECT * FROM generate_series(0, $1) num', [ 1000000, ]); if (query.state || (query.cursor && query.cursor.state)) { console.log('ok'); } ================================================ FILE: test/test-79-npm/pg-query-stream/pg-query-stream@1.0.0.meta.js ================================================ 'use strict'; module.exports = function () { return { packages: ['pg'], }; }; ================================================ FILE: test/test-79-npm/pg-types/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/pg-types/pg-types.js ================================================ 'use strict'; require('pg-types'); var scriptToCheck = 'pg-types/lib/textParsers.js'; require(scriptToCheck, 'must-exclude'); console.log('ok'); ================================================ FILE: test/test-79-npm/pg-types/pg-types@1.0.0.js ================================================ 'use strict'; require('./pg-types.js'); ================================================ FILE: test/test-79-npm/pg.js/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/pg.js/pg.js.js ================================================ 'use strict'; var pg = require('pg.js'); if (pg.connect) { console.log('ok'); } ================================================ FILE: test/test-79-npm/pg.js/pg.js@3.6.2.js ================================================ 'use strict'; require('./pg.js.js'); ================================================ FILE: test/test-79-npm/pg.js/pg.js@4.1.0.js ================================================ 'use strict'; require('./pg.js.js'); ================================================ FILE: test/test-79-npm/pgpass/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/pgpass/pgpass.js ================================================ 'use strict'; var pgpass = require('pgpass'); var connection = { host: 'pgserver', user: 'the_user_name', }; pgpass(connection, function () { console.log('ok'); }); ================================================ FILE: test/test-79-npm/phantom/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/phantom/phantom.js ================================================ 'use strict'; var phantom = require('phantom'); var instance, page; Promise.resolve() .then(function () { return phantom.create(); }) .then(function (i) { instance = i; return instance.createPage(); }) .then(function (p) { page = p; return page.open('https://stackoverflow.com/'); }) .then(function () { return page.property('content'); }) .then(function (content) { if (content.length > 1000) console.log('ok'); return instance.exit(); }); ================================================ FILE: test/test-79-npm/phantom/phantom.meta.js ================================================ 'use strict'; module.exports = function (stamp) { return { allow: !/^arm/.test(stamp.a), deployFilesFrom: ['phantom', 'phantomjs-prebuilt'], }; }; ================================================ FILE: test/test-79-npm/phantomjs-prebuilt/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/phantomjs-prebuilt/phantomjs-prebuilt.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); var phantomjs = require('phantomjs-prebuilt'); var filename = phantomjs.path; if ( fs.existsSync(filename) && path.isAbsolute(filename) && filename.indexOf('snapshot') < 0 ) { console.log('ok'); } ================================================ FILE: test/test-79-npm/phantomjs-prebuilt/phantomjs-prebuilt.meta.js ================================================ 'use strict'; module.exports = function (stamp) { return { allow: !/^arm/.test(stamp.a), deployFilesFrom: ['phantomjs-prebuilt'], }; }; ================================================ FILE: test/test-79-npm/pkginfo/package.json ================================================ { "private": true, "fixture": "fixture-text" } ================================================ FILE: test/test-79-npm/pkginfo/pkginfo.js ================================================ 'use strict'; require('./package.json'); // to include require('pkginfo')(module); // changes module.exports if (module.exports.fixture === 'fixture-text') { console.log('ok'); } ================================================ FILE: test/test-79-npm/pkginfo/pkginfo@0.2.1.js ================================================ 'use strict'; // to check that readdir-based // pkginfo version also works require('./pkginfo.js'); ================================================ FILE: test/test-79-npm/pm2/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/pm2/test.it.manually.meta.js ================================================ // pm2 оставляет следы в системе. придумай как // его проверить без установки демона ================================================ FILE: test/test-79-npm/pmx/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/pmx/pmx.js ================================================ 'use strict'; var pmx = require('pmx'); if (pmx.http) { console.log('ok'); } ================================================ FILE: test/test-79-npm/pmx/pmx@0.5.9.js ================================================ 'use strict'; require('./pmx.js'); ================================================ FILE: test/test-79-npm/pouchdb/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/pouchdb/pouchdb.js ================================================ 'use strict'; var PouchDB = require('pouchdb'); var db = new PouchDB('dbname'); var rimraf = require('../../../node_modules/rimraf'); (function (cb) { db.put( { _id: 'dave@gmail.com', name: 'David', age: 68, }, function (error1) { if (error1) return cb(error1); db.get('dave@gmail.com', function (error2, data) { if (error2) return cb(error2); if (data.age === 68) { console.log('ok'); return cb(); } }); } ); })(function (error) { if (error) throw error; db.close(function () { rimraf.sync('dbname'); }); }); ================================================ FILE: test/test-79-npm/pouchdb/pouchdb.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), build: 'leveldown', }; }; ================================================ FILE: test/test-79-npm/primus/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/primus/primus.js ================================================ 'use strict'; var primus = require('primus'); if (primus.transformers) { console.log('ok'); } ================================================ FILE: test/test-79-npm/primus-emitter/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/primus-emitter/primus-emitter.js ================================================ 'use strict'; var emitter = require('primus-emitter'); if (emitter.Emitter) { console.log('ok'); } ================================================ FILE: test/test-79-npm/primus-spark-latency/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/primus-spark-latency/primus-spark-latency.js ================================================ 'use strict'; var latency = require('primus-spark-latency'); if (latency.server) { console.log('ok'); } ================================================ FILE: test/test-79-npm/publicsuffixlist/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/publicsuffixlist/publicsuffixlist.js ================================================ 'use strict'; if (process.pkg) { let hasBadDeps = true; try { require('./node_modules/istanbul', 'must-exclude'); } catch (_) { hasBadDeps = false; } // istanbul must be in devDeps, not in deps if (hasBadDeps) return; } var PublicSuffixList = require('publicsuffixlist'); var list = new PublicSuffixList(); list.initializeSync(); var result = list.lookup('www.domain.com'); if (result.tld === 'com') { console.log('ok'); } ================================================ FILE: test/test-79-npm/pug/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/pug/pug.js ================================================ 'use strict'; // see also express.js var file = 'html\n' + ' head\n' + ' title!= title\n' + ' body\n' + ' h1!= message\n'; var pug = require('pug'); var fn = pug.compile(file, {}); var html = fn({ title: 'Hey', message: 'Hello there!' }); if ( html === 'Hey' + '

Hello there!

' ) { console.log('ok'); } ================================================ FILE: test/test-79-npm/punt/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/punt/punt.js ================================================ 'use strict'; var punt = require('punt'); if (punt.bind && punt.connect) { console.log('ok'); } ================================================ FILE: test/test-79-npm/punt/punt@1.0.1.js ================================================ 'use strict'; require('./punt.js'); ================================================ FILE: test/test-79-npm/puppeteer/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/puppeteer/puppeteer.js ================================================ 'use strict'; var fs = require('fs'); var puppeteer = require('puppeteer'); puppeteer.launch().then(function (browser) { browser.newPage().then(function (page) { page .goto('https://zeit.co') .then(function () { page.screenshot({ path: 'zeit.png' }).then(function () { browser.close(); fs.unlinkSync('zeit.png'); console.log('ok'); }); }) .catch((error) => { console.error(error); process.exit(1); }); }); }); ================================================ FILE: test/test-79-npm/puppeteer/puppeteer.meta.js ================================================ 'use strict'; module.exports = function (stamp, flags) { if (flags.ci) { return { allow: false, note: 'headless CI seems to fail headful chromium', }; } return { deployFilesFrom: ['puppeteer'], }; }; ================================================ FILE: test/test-79-npm/pwd/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/pwd/pwd.js ================================================ 'use strict'; var pwd = require('pwd'); if (pwd.hash) { console.log('ok'); } ================================================ FILE: test/test-79-npm/pwd/pwd@0.0.4.js ================================================ 'use strict'; require('./pwd.js'); ================================================ FILE: test/test-79-npm/q/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/q/q.js ================================================ 'use strict'; var q = require('q'); if (q.join) { console.log('ok'); } ================================================ FILE: test/test-79-npm/raven/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/raven/raven.js ================================================ 'use strict'; require('raven'); console.log('ok'); ================================================ FILE: test/test-79-npm/rc/.fixture.for.rc ================================================ NAME=VALUE ================================================ FILE: test/test-79-npm/rc/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/rc/rc.config.json ================================================ { "bin": "rc.js", "pkg": { "assets": [".fixture.for.rc"] } } ================================================ FILE: test/test-79-npm/rc/rc.js ================================================ 'use strict'; var conf = require('rc')('fixture.for.', {}); if (conf.NAME === 'VALUE') { console.log('ok'); } ================================================ FILE: test/test-79-npm/readable-stream/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/readable-stream/readable-stream.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); var fst = fs.createReadStream(path.join(__dirname, 'readable-stream.js')); var Readable = require('readable-stream'); var rst = new Readable(); rst.wrap(fst); setTimeout(function () { var test = "'use strict';"; var c = rst.read(test.length); if (c.toString() === test) { console.log('ok'); } }, 100); ================================================ FILE: test/test-79-npm/rechoir/fixture.coffee ================================================ module.exports = root: Math.sqrt cube: (x) -> x * square x ================================================ FILE: test/test-79-npm/rechoir/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/rechoir/rechoir.config.json ================================================ { "bin": "rechoir.js", "pkg": { "assets": ["fixture.coffee"] } } ================================================ FILE: test/test-79-npm/rechoir/rechoir.js ================================================ 'use strict'; var path = require('path'); var config = require('interpret').extensions; var rechoir = require('rechoir'); require('coffee-script/register'); rechoir.prepare(config, './fixture.coffee'); var filename = path.join(__dirname, 'fixture.coffee'); var coffee = require(filename); if (typeof coffee.root === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/rechoir/rechoir.meta.js ================================================ 'use strict'; module.exports = function () { return { packages: ['coffee-script', 'interpret'], }; }; ================================================ FILE: test/test-79-npm/redis/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/redis/redis.js ================================================ 'use strict'; var redis = require('redis'); var client = redis.createClient(); client.on('error', function (error) { var ok = error.message.indexOf('ECONNREFUSED') >= 0; if (ok) console.log('ok'); process.exit(); }); ================================================ FILE: test/test-79-npm/redis/redis@1.0.0.js ================================================ 'use strict'; require('./redis.js'); ================================================ FILE: test/test-79-npm/redis/redis@2.0.1.js ================================================ 'use strict'; require('./redis.js'); ================================================ FILE: test/test-79-npm/redis/redis@2.1.0.js ================================================ 'use strict'; require('./redis.js'); ================================================ FILE: test/test-79-npm/redis/redis@2.2.5.js ================================================ 'use strict'; require('./redis.js'); ================================================ FILE: test/test-79-npm/redis/redis@2.3.1.js ================================================ 'use strict'; require('./redis.js'); ================================================ FILE: test/test-79-npm/redis/redis@2.4.2.js ================================================ 'use strict'; require('./redis.js'); ================================================ FILE: test/test-79-npm/redis-parser/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/redis-parser/redis-parser.js ================================================ 'use strict'; var Parser = require('redis-parser'); var parser = new Parser({ name: 'auto', returnReply: function (reply) { console.log(reply); }, returnError: function (error) { console.log(error); }, returnFatalError: function (error) { console.log(error); }, }); if (Array.isArray(parser.bufferCache)) { console.log('ok'); } ================================================ FILE: test/test-79-npm/redis-with-hiredis/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis.js ================================================ 'use strict'; var redis = require('redis'); var client = redis.createClient(); client.on('error', function (error) { var ok = error.message.indexOf('ECONNREFUSED') >= 0; if (ok) console.log('ok'); process.exit(); }); ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis.meta.js ================================================ 'use strict'; module.exports = function () { return { packages: ['hiredis'], }; }; ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis@1.0.0.js ================================================ 'use strict'; require('./redis.js'); ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis@1.0.0.meta.js ================================================ 'use strict'; module.exports = require('./redis.meta.js'); ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis@2.0.1.js ================================================ 'use strict'; require('./redis.js'); ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis@2.0.1.meta.js ================================================ 'use strict'; module.exports = require('./redis.meta.js'); ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis@2.1.0.js ================================================ 'use strict'; require('./redis.js'); ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis@2.1.0.meta.js ================================================ 'use strict'; module.exports = require('./redis.meta.js'); ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis@2.2.5.js ================================================ 'use strict'; require('./redis.js'); ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis@2.2.5.meta.js ================================================ 'use strict'; module.exports = require('./redis.meta.js'); ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis@2.3.1.js ================================================ 'use strict'; require('./redis.js'); ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis@2.3.1.meta.js ================================================ 'use strict'; module.exports = require('./redis.meta.js'); ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis@2.4.2.js ================================================ 'use strict'; require('./redis.js'); ================================================ FILE: test/test-79-npm/redis-with-hiredis/redis@2.4.2.meta.js ================================================ 'use strict'; module.exports = require('./redis.meta.js'); ================================================ FILE: test/test-79-npm/regression/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/regression/regression.js ================================================ 'use strict'; var regression = require('regression'); if (typeof regression.linear === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/regression/regression@1.4.0.js ================================================ 'use strict'; var regression = require('regression'); if (typeof regression === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/reload/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/reload/reload.js ================================================ 'use strict'; require('./reload@2.1.0.js'); ================================================ FILE: test/test-79-npm/reload/reload.meta.js ================================================ 'use strict'; module.exports = require('./reload@2.1.0.meta.js'); ================================================ FILE: test/test-79-npm/reload/reload@2.1.0.js ================================================ 'use strict'; var http = require('http'); require('reload/bin/reload'); setTimeout(function () { http.get('http://127.0.0.1:8080/', function (res) { var chunks = ''; res .on('data', function (chunk) { chunks += chunk.toString(); }) .on('end', function () { if (chunks === "Can't find index.html" || chunks === 'File Not Found') { console.log('ok'); } process.exit(); }); }); }, 500); ================================================ FILE: test/test-79-npm/reload/reload@2.1.0.meta.js ================================================ 'use strict'; module.exports = function () { return { take: 'last-line', }; }; ================================================ FILE: test/test-79-npm/request/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/request/request.js ================================================ 'use strict'; var request = require('request'); if (request.get) { console.log('ok'); } ================================================ FILE: test/test-79-npm/require-uncached/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/require-uncached/require-uncached.js ================================================ 'use strict'; require('acorn'); // in order to take var require2 = require('require-uncached'); var dep = 'acorn'; var result = require2(dep); if (typeof result !== 'undefined') { console.log('ok'); } ================================================ FILE: test/test-79-npm/require_optional/package.json ================================================ { "private": true, "peerOptionalDependencies": { "chalk": "*" } } ================================================ FILE: test/test-79-npm/require_optional/require_optional.config.json ================================================ { "bin": "require_optional.js", "pkg": { "assets": ["package.json"] } } ================================================ FILE: test/test-79-npm/require_optional/require_optional.js ================================================ 'use strict'; var require2 = require('require_optional'); var chalk = require2('chalk'); if (typeof chalk === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/s3/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/s3/s3.js ================================================ 'use strict'; var s3 = require('s3'); var client = s3.createClient({ s3Options: { accessKeyId: 'ABRACADABRABRACADABR', secretAccessKey: 'TdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTdTd', }, }); var ee = client.listObjects({ s3Params: { Bucket: 'enclosejs', }, }); ee.on('error', function (error) { if (error) { if (error.message.indexOf('does not exist') >= 0) { console.log('ok'); } } }); ================================================ FILE: test/test-79-npm/safe_datejs/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/safe_datejs/safe_datejs.js ================================================ 'use strict'; require('safe_datejs'); var today = new Date(2011, 11, 12, 0, 0, 0, 0); var wrap = today.AsDateJs(); // eslint-disable-line new-cap if (wrap.is().today() === false) { console.log('ok'); } ================================================ FILE: test/test-79-npm/sails/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/sails/sails.js ================================================ 'use strict'; console.log('ok'); ================================================ FILE: test/test-79-npm/sails/sails.meta.js ================================================ 'use strict'; module.exports = function () { return { allow: false, // TODO not that simple to test. but may be try? }; }; ================================================ FILE: test/test-79-npm/sax/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/sax/sax.js ================================================ 'use strict'; var sax = require('sax'); var parser = sax.parser(true); parser.onopentag = function (node) { if (node.name === 'hello') { console.log('ok'); } }; parser.write('World!').close(); ================================================ FILE: test/test-79-npm/scrypt/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/scrypt/scrypt.js ================================================ 'use strict'; var scrypt = require('scrypt'); if (scrypt.hashSync) { console.log('ok'); } ================================================ FILE: test/test-79-npm/scrypt/scrypt.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), }; }; ================================================ FILE: test/test-79-npm/scrypt/scrypt@5.4.1.js ================================================ 'use strict'; require('./scrypt.js'); ================================================ FILE: test/test-79-npm/scrypt/scrypt@5.4.1.meta.js ================================================ 'use strict'; module.exports = require('./scrypt.meta.js'); ================================================ FILE: test/test-79-npm/semver/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/semver/semver.js ================================================ 'use strict'; var semver = require('semver'); if (semver.SEMVER_SPEC_VERSION) { console.log('ok'); } ================================================ FILE: test/test-79-npm/sequelize/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/sequelize/sequelize.config.json ================================================ { "bin": "sequelize.js", "dependencies": { "mysql2": "*", "pg": "*", "pg-hstore": "*", "sqlite3": "*", "tedious": "*" } } ================================================ FILE: test/test-79-npm/sequelize/sequelize.js ================================================ 'use strict'; var sequelize = require('sequelize'); if (typeof sequelize.and !== 'function') return; var Dialect2 = require('sequelize/lib/dialects/mssql'); var db2 = new Dialect2({ config: {}, options: { dialect: 'mssql' } }); var cm2 = db2.connectionManager; if (typeof cm2.lib.Connection !== 'function') return; var Dialect3 = require('sequelize/lib/dialects/mysql'); var db3 = new Dialect3({ config: {}, options: { dialect: 'mysql' } }); var cm3 = db3.connectionManager; if (typeof cm3.lib.createConnection !== 'function') return; var Dialect4 = require('sequelize/lib/dialects/postgres'); var db4 = new Dialect4({ config: {}, options: { dialect: 'postgres' } }); var cm4 = db4.connectionManager; if (typeof cm4.lib.Connection !== 'function') return; var Dialect5 = require('sequelize/lib/dialects/sqlite'); var db5 = new Dialect5({ config: {}, options: { dialect: 'sqlite' } }); var cm5 = db5.connectionManager; if (typeof cm5.lib.Database !== 'function') return; console.log('ok'); ================================================ FILE: test/test-79-npm/sequelize/sequelize.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), packages: ['mysql2', 'pg', 'pg-hstore', 'sqlite3', 'tedious'], }; }; ================================================ FILE: test/test-79-npm/sequelize/sequelize@3.30.4.config.json ================================================ { "bin": "sequelize@3.30.4.js", "dependencies": { "mysql": "*", "pg": "*", "pg-hstore": "*", "sqlite3": "*", "tedious": "*" } } ================================================ FILE: test/test-79-npm/sequelize/sequelize@3.30.4.js ================================================ 'use strict'; var sequelize = require('sequelize'); if (typeof sequelize.and !== 'function') return; var Dialect1 = require('sequelize/lib/dialects/mariadb'); var db1 = new Dialect1({ config: {}, options: { dialect: 'mariadb' } }); var cm1 = db1.connectionManager; if (typeof cm1.lib.createConnection !== 'function') return; var Dialect2 = require('sequelize/lib/dialects/mssql'); var db2 = new Dialect2({ config: {}, options: { dialect: 'mssql' } }); var cm2 = db2.connectionManager; if (typeof cm2.lib.Connection !== 'function') return; var Dialect3 = require('sequelize/lib/dialects/mysql'); var db3 = new Dialect3({ config: {}, options: { dialect: 'mysql' } }); var cm3 = db3.connectionManager; if (typeof cm3.lib.createConnection !== 'function') return; var Dialect4 = require('sequelize/lib/dialects/postgres'); var db4 = new Dialect4({ config: {}, options: { dialect: 'postgres' } }); var cm4 = db4.connectionManager; if (typeof cm4.lib.Connection !== 'function') return; var Dialect5 = require('sequelize/lib/dialects/sqlite'); var db5 = new Dialect5({ config: {}, options: { dialect: 'sqlite' } }); var cm5 = db5.connectionManager; if (typeof cm5.lib.Database !== 'function') return; console.log('ok'); ================================================ FILE: test/test-79-npm/sequelize/sequelize@3.30.4.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), packages: ['mysql', 'pg', 'pg-hstore', 'sqlite3', 'tedious'], }; }; ================================================ FILE: test/test-79-npm/serialport/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/serialport/serialport.js ================================================ 'use strict'; var serialport = require('serialport'); if (typeof serialport.list === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/serialport/serialport.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), }; }; ================================================ FILE: test/test-79-npm/sha3/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/sha3/sha3.js ================================================ 'use strict'; var sha3 = require('sha3'); if (sha3.SHA3Hash) { console.log('ok'); } ================================================ FILE: test/test-79-npm/sha3/sha3.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), }; }; ================================================ FILE: test/test-79-npm/sharp/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/sharp/sharp.js ================================================ 'use strict'; var sharp = require('sharp'); var source = Buffer.from( '' ); sharp(source) .rotate() .toBuffer() .then(function (output) { if (output.slice(1, 4).toString() === 'PNG') { console.log('ok'); process.exit(); } }) .catch((error) => { console.error(error); process.exit(1); }); setTimeout(() => { // if test does not pass, it blocks // any other way to exit process.kill(process.pid); }, 3000); ================================================ FILE: test/test-79-npm/sharp/sharp.meta.js ================================================ 'use strict'; module.exports = function () { return { deployFilesFrom: ['sharp'], }; }; ================================================ FILE: test/test-79-npm/shelljs/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/shelljs/shelljs.js ================================================ 'use strict'; var shell = require('shelljs'); var windows = process.platform === 'win32'; var result = shell.exec(windows ? 'dir' : 'ls', { silent: true }); var data = result.stdout || result.output; if (data.length >= 2) { console.log('ok'); } ================================================ FILE: test/test-79-npm/shelljs/shelljs@0.1.4.js ================================================ 'use strict'; require('./shelljs.js'); ================================================ FILE: test/test-79-npm/shelljs/shelljs@0.6.0.js ================================================ 'use strict'; require('./shelljs.js'); ================================================ FILE: test/test-79-npm/shelljs/shelljs@0.7.6.js ================================================ 'use strict'; require('./shelljs.js'); ================================================ FILE: test/test-79-npm/sinon/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/sinon/sinon.js ================================================ 'use strict'; var sinon = require('sinon'); var callback = sinon.spy(); callback(); if (callback.called) { console.log('ok'); } ================================================ FILE: test/test-79-npm/sinon/sinon@1.1.0.js ================================================ 'use strict'; require('./sinon.js'); ================================================ FILE: test/test-79-npm/socket.io/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/socket.io/socket.io.js ================================================ 'use strict'; var http = require('http'); var io = require('socket.io')(); io.on('connection', function () {}); io.listen(3000); setTimeout(function () { http.get('http://127.0.0.1:3000/socket.io/socket.io.js', function (res) { var chunks = ''; res .on('data', function (chunk) { chunks += chunk.toString(); }) .on('end', function () { if (chunks.indexOf('BINARY_ACK') >= 0) { console.log('ok'); } io.close(); }); }); }, 100); ================================================ FILE: test/test-79-npm/socket.io/socket.io@1.4.8.js ================================================ 'use strict'; var http = require('http'); var io = require('socket.io')(); io.on('connection', function () {}); io.listen(3000); setTimeout(function () { http.get('http://127.0.0.1:3000/socket.io/socket.io.js', function (res) { var chunks = ''; res .on('data', function (chunk) { chunks += chunk.toString(); }) .on('end', function () { if (chunks.indexOf('_dereq_') >= 0) { console.log('ok'); } io.close(); }); }); }, 100); ================================================ FILE: test/test-79-npm/socket.io/socket.io@1.6.0.js ================================================ 'use strict'; var http = require('http'); var io = require('socket.io')(); io.on('connection', function () {}); io.listen(3000); setTimeout(function () { http.get('http://127.0.0.1:3000/socket.io/socket.io.js', function (res) { var chunks = ''; res .on('data', function (chunk) { chunks += chunk.toString(); }) .on('end', function () { if (chunks.indexOf('__webpack_require__') >= 0) { console.log('ok'); } io.close(); }); }); }, 100); ================================================ FILE: test/test-79-npm/socket.io/socket.io@1.7.0.js ================================================ 'use strict'; require('./socket.io.js'); ================================================ FILE: test/test-79-npm/socket.io-client/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/socket.io-client/socket.io-client.js ================================================ 'use strict'; var fs = require('fs'); var client = require('socket.io-client'); if (typeof client.protocol === 'number') { var literal = 'socket.io-client/dist/socket.io.js'; var p = require.resolve(literal, 'may-exclude'); var asset = fs.readFileSync(p, 'utf8'); if (asset.length > 100) { console.log('ok'); } } ================================================ FILE: test/test-79-npm/socket.io-client/socket.io-client@0.9.17.js ================================================ 'use strict'; var fs = require('fs'); var client = require('socket.io-client'); if (typeof client.protocol === 'number') { var literal = 'socket.io-client/dist/socket.io.js'; var path = require.resolve(literal, 'may-exclude'); var asset = fs.readFileSync(path, 'utf8'); var literalMin = 'socket.io-client/dist/socket.io.min.js'; var pathMin = require.resolve(literalMin, 'may-exclude'); var assetMin = fs.readFileSync(pathMin, 'utf8'); if (asset.length > 100 && assetMin.length > 100) { console.log('ok'); } } ================================================ FILE: test/test-79-npm/socket.io-client/socket.io-client@1.0.6.js ================================================ 'use strict'; var fs = require('fs'); var client = require('socket.io-client'); if (typeof client.protocol === 'number') { var literal = 'socket.io-client/socket.io.js'; var p = require.resolve(literal, 'may-exclude'); var asset = fs.readFileSync(p, 'utf8'); if (asset.length > 100) { console.log('ok'); } } ================================================ FILE: test/test-79-npm/socket.io-client/socket.io-client@1.7.0.js ================================================ 'use strict'; require('./socket.io-client.js'); ================================================ FILE: test/test-79-npm/sqip/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/sqip/sqip.js ================================================ 'use strict'; var sqip = require('sqip'); if (sqip !== undefined) { console.log('ok'); } ================================================ FILE: test/test-79-npm/sqlite3/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/sqlite3/sqlite3.js ================================================ 'use strict'; var sqlite3 = require('sqlite3'); if (typeof sqlite3.verbose === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/sqlite3/sqlite3.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), }; }; ================================================ FILE: test/test-79-npm/stamp.js ================================================ #!/usr/bin/env node 'use strict'; var o = { p: process.platform, a: process.arch, m: parseInt(process.versions.modules, 10), }; if (module.parent) { module.exports = o; } else { process.stdout.write(JSON.stringify(o)); } ================================================ FILE: test/test-79-npm/steam/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/steam/steam.js ================================================ 'use strict'; var Steam = require('steam'); var steamClient = new Steam.SteamClient(); if (typeof steamClient.connect === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/steam/steam.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp) && stamp.m >= 46, }; }; ================================================ FILE: test/test-79-npm/steam-crypto/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/steam-crypto/steam-crypto.js ================================================ 'use strict'; var sc = require('steam-crypto'); if (sc.generateSessionKey) { console.log('ok'); } ================================================ FILE: test/test-79-npm/stripe/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/stripe/stripe.js ================================================ 'use strict'; var stripe = require('stripe'); if (stripe.DEFAULT_HOST === 'api.stripe.com') { console.log('ok'); } ================================================ FILE: test/test-79-npm/stripe/stripe@3.9.0.js ================================================ 'use strict'; require('./stripe.js'); ================================================ FILE: test/test-79-npm/stripe-webhook-middleware/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/stripe-webhook-middleware/stripe-webhook-middleware.js ================================================ 'use strict'; var StripeWebhook = require('stripe-webhook-middleware'); var req = { headers: {}, body: { id: 'hello' } }; var res = { status: function () { return this; }, end: function () { console.log('ok'); }, }; var middleware = new StripeWebhook().middleware; middleware(req, res, function () {}); ================================================ FILE: test/test-79-npm/strong-globalize/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/strong-globalize/strong-globalize.js ================================================ 'use strict'; var SG = require('strong-globalize'); if (typeof SG.SetRootDir === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/stylus/external.css ================================================ .foo .bar { width: 10px; } ================================================ FILE: test/test-79-npm/stylus/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/stylus/stylus.config.json ================================================ { "bin": "stylus.js", "pkg": { "assets": ["external.css"] } } ================================================ FILE: test/test-79-npm/stylus/stylus.js ================================================ 'use strict'; var path = require('path'); var stylus = require('stylus'); var s = '@require "external.css"'; var opts = { filename: 'index.css', paths: [__dirname] }; var dep = stylus(s, opts).deps()[0]; if (path.basename(dep) === 'external.css') { stylus.render(s, opts, function (error, css) { if (error) return; if (css === '@import "external.css";\n') { console.log('ok'); } }); } ================================================ FILE: test/test-79-npm/supervisor/fixture.js ================================================ 'use strict'; console.error('ok'); ================================================ FILE: test/test-79-npm/supervisor/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/supervisor/supervisor.js ================================================ 'use strict'; var supervisor = require('supervisor'); var program = require.resolve('./fixture.js'); var args = ['-n', 'success', program]; supervisor.run(args); setTimeout(function () { process.exit(); }, 500); ================================================ FILE: test/test-79-npm/supervisor/supervisor.meta.js ================================================ 'use strict'; module.exports = function () { return { take: 'stderr', }; }; ================================================ FILE: test/test-79-npm/svgo/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/svgo/svgo.js ================================================ 'use strict'; var svgo = require('svgo'); if (svgo !== undefined) { console.log('ok'); } ================================================ FILE: test/test-79-npm/tabtab/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/tabtab/tabtab.js ================================================ 'use strict'; var tabtab = require('tabtab'); if (typeof tabtab === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/tesseract.js/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/tesseract.js/tesseract.js.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); var Tesseract = require('tesseract.js'); var image = path.join(__dirname, 'hello.jpg'); Tesseract.recognize(image) .then(function ({ data }) { if (data && data.text && typeof data.text === 'string') { if (data.text.toLowerCase().indexOf('hello') >= 0) { console.log('ok'); } else { console.log(data.text.replace(/\n/g, '\\n')); } } else { console.log(data); } }) .catch(function (error) { console.log(error); }) .finally(function () { fs.unlinkSync('eng.traineddata'); process.exit(); }); ================================================ FILE: test/test-79-npm/tesseract.js/tesseract.js.meta.js ================================================ 'use strict'; module.exports = function () { return { take: 'last-line', }; }; ================================================ FILE: test/test-79-npm/throng/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/throng/throng.js ================================================ 'use strict'; var throng = require('throng'); throng(8, function (id) { if (id === 7) { console.log('ok'); } }); setTimeout(function () { process.exit(); }, 5000); ================================================ FILE: test/test-79-npm/throng/throng.meta.js ================================================ 'use strict'; module.exports = function (stamp) { return { allow: stamp.m >= 46, }; }; ================================================ FILE: test/test-79-npm/time/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/time/time.js ================================================ 'use strict'; var time = require('time'); var now = new time.Date(); now.setTimezone('America/Los_Angeles'); var s = now.toString(); if (s.length > 5) { console.log('ok'); } ================================================ FILE: test/test-79-npm/time/time.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), }; }; ================================================ FILE: test/test-79-npm/times.js ================================================ 'use strict'; const https = require('https'); const foldyNames = process.argv[2].split(','); const results = {}; process.on('exit', function () { console.log(JSON.stringify(results)); }); for (let i = 0; i < 10; i += 1) { nextJob(); } function nextJob() { if (foldyNames.length === 0) return; queueJob(foldyNames.shift()); } function queueJob(foldyName) { getLatestTime(foldyName, function (error, latestTime) { if (error) console.error(error); results[foldyName] = new Date(latestTime).getTime(); setTimeout(nextJob, 0); }); } function getLatestTime(foldyName, cb) { https .get('https://registry.npmjs.org/' + foldyName, function (response) { let s = ''; response.on('data', function (chunk) { s += chunk; }); response.on('end', function () { const json = JSON.parse(s); const distTags = json['dist-tags']; if (!distTags) return cb(undefined, Date.now()); // express-with-jade const latest = distTags.latest; cb(undefined, json.time[latest]); }); response.on('error', function (error) { cb(error); }); }) .on('error', function (error) { cb(error); }); } ================================================ FILE: test/test-79-npm/tinify/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/tinify/tinify.js ================================================ 'use strict'; var tinify = require('tinify'); if (tinify !== undefined) { console.log('ok'); } ================================================ FILE: test/test-79-npm/tiny-worker/fixture.js ================================================ /* eslint-disable no-undef */ 'use strict'; onmessage = function (ev) { postMessage(ev.data.slice(0, 2)); }; ================================================ FILE: test/test-79-npm/tiny-worker/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/tiny-worker/tiny-worker.js ================================================ 'use strict'; var Worker = require('tiny-worker'); var worker = new Worker('fixture.js'); worker.onmessage = function (ev) { console.log(ev.data); worker.terminate(); }; worker.postMessage('ok?'); ================================================ FILE: test/test-79-npm/tmp/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/tmp/tmp.js ================================================ 'use strict'; var tmp = require('tmp'); if (tmp.fileSync) { console.log('ok'); } ================================================ FILE: test/test-79-npm/transformers/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/transformers/transformers.js ================================================ 'use strict'; var transformers = require('transformers'); try { transformers.ejs.loadModule(); } catch (e) { if (e.code === 'MODULE_NOT_FOUND') { console.log('ok'); } } ================================================ FILE: test/test-79-npm/uglify-js/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/uglify-js/uglify-js.js ================================================ 'use strict'; var ujs = require('uglify-js'); var code = 'var b = function () {};'; var result = ujs.minify(code); if (result.code === 'var b=function(){};') { console.log('ok'); } ================================================ FILE: test/test-79-npm/uglify-js/uglify-js@2.7.5.js ================================================ 'use strict'; var ujs = require('uglify-js'); var code = '40 + 2'; var ast = ujs.parse(code, {}); if (ast.body[0].body.operator === '+') { var code2 = 'var b = function () {};'; var result = ujs.minify(code2, { fromString: true }); if (result.code === 'var b=function(){};') { console.log('ok'); } } ================================================ FILE: test/test-79-npm/umd/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/umd/umd.js ================================================ 'use strict'; var umd = require('umd'); if (umd.prelude) { console.log('ok'); } ================================================ FILE: test/test-79-npm/umd/umd@2.1.0.js ================================================ 'use strict'; require('./umd.js'); ================================================ FILE: test/test-79-npm/underscore/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/underscore/underscore.js ================================================ 'use strict'; var underscore = require('underscore'); if (typeof underscore === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/union/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/union/union.js ================================================ 'use strict'; var union = require('union'); if (typeof union.createServer === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/update-notifier/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/update-notifier/update-notifier.js ================================================ 'use strict'; // anyway testing in ci require('ci-info').isCI = false; var spawnWasCalled; var save = require('child_process').spawn; require('child_process').spawn = function () { spawnWasCalled = true; return save.apply(this, arguments); // eslint-disable-line prefer-rest-params }; var updateNotifier = require('update-notifier'); var pjson = { name: 'pkg', version: '3.0.0' }; var notifier; function runNotifier() { notifier = updateNotifier({ pkg: pjson, updateCheckInterval: 0, }); setTimeout(function () { if ( spawnWasCalled && notifier.update && notifier.update.current === '3.0.0' ) { console.log('ok'); process.exit(0); } else { runNotifier(); } }, 1984); } runNotifier(); ================================================ FILE: test/test-79-npm/update-notifier/update-notifier.meta.js ================================================ 'use strict'; module.exports = function (stamp, flags) { if (flags.ci) { return { allow: false, }; } }; ================================================ FILE: test/test-79-npm/usage/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/usage/usage.js ================================================ 'use strict'; var usage = require('usage'); var pid = process.pid; usage.lookup(pid, function (error, result) { if (error) throw error; if (result.memory) console.log('ok'); }); ================================================ FILE: test/test-79-npm/usage/usage.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp) && stamp.p !== 'win32', note: 'windows is not supported', }; }; ================================================ FILE: test/test-79-npm/v8flags/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/v8flags/v8flags.js ================================================ /* eslint-disable no-underscore-dangle */ 'use strict'; var cp = require('child_process'); require('module')._extensions['.json'] = function () { throw new Error('prevent loading json cache'); }; var execFileCalled = false; var execFileSave = cp.execFile; cp.execFile = function () { execFileCalled = true; execFileSave.apply(cp, arguments); // eslint-disable-line prefer-rest-params }; setTimeout(function () { var v8flags = require('v8flags'); v8flags(function (error, results) { if (error) return; if (!Array.isArray(results)) return; if (results.length < 6) return; if (!execFileCalled) return; console.log('ok'); }); }, 500); ================================================ FILE: test/test-79-npm/v8flags/v8flags@2.1.1.js ================================================ /* eslint-disable no-underscore-dangle */ 'use strict'; var cp = require('child_process'); require('module')._extensions['.json'] = function () { throw new Error('prevent loading json cache'); }; var execFileCalled = false; var execFileSave = cp.execFile; cp.execFile = function () { execFileCalled = true; execFileSave.apply(cp, arguments); // eslint-disable-line prefer-rest-params }; setTimeout(function () { var v8flags = require('v8flags'); v8flags(function (error, results) { if (error) return; if (!Array.isArray(results)) return; if (results.length < 6) return; if (!execFileCalled) return; console.log('ok'); }); }, 500); ================================================ FILE: test/test-79-npm/verror/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/verror/verror.js ================================================ 'use strict'; var verror = require('verror'); if (typeof verror === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/voc/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/voc/voc.js ================================================ 'use strict'; var voc = require('voc'); if (typeof voc.run === 'function') { console.log('ok'); } ================================================ FILE: test/test-79-npm/webdriverio/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/webdriverio/webdriverio.js ================================================ 'use strict'; var webdriverio = require('webdriverio'); var client = webdriverio.remote().init(); client.url('http://google.com').catch((e) => { if (e.message.includes('ECONNREFUSED')) { console.log('ok'); } }); ================================================ FILE: test/test-79-npm/winston/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/winston/winston.js ================================================ /* eslint-disable no-underscore-dangle */ 'use strict'; process.stdout._write_ = process.stdout.write; process.stdout.write = function (m) { process.stdout._write_(m.slice(m.indexOf(': ') + 2)); }; var winston = require('winston'); var Logger = winston.Logger; var Console = winston.transports.Console; new Logger({ transports: [new Console()] }); // eslint-disable-line no-new winston.log('info', 'ok'); ================================================ FILE: test/test-79-npm/winston-uber/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/winston-uber/winston-uber.js ================================================ /* eslint-disable no-underscore-dangle */ 'use strict'; process.stdout._write_ = process.stdout.write; process.stdout.write = function (m) { process.stdout._write_(m.slice(m.indexOf(': ') + 2)); }; var winston = require('winston-uber'); var Logger = winston.Logger; var Console = winston.transports.Console; new Logger({ transports: [new Console()] }); // eslint-disable-line no-new winston.log('info', 'ok'); ================================================ FILE: test/test-79-npm/ws/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/ws/ws.js ================================================ 'use strict'; var WebSocket = require('ws'); var ws = new WebSocket('ws://127.0.0.1/'); ws.on('error', function () { console.log('ok'); }); ================================================ FILE: test/test-79-npm/ws/ws@0.5.0.js ================================================ 'use strict'; require('./ws.js'); ================================================ FILE: test/test-79-npm/xlsx/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/xlsx/xlsx.js ================================================ 'use strict'; var path = require('path'); var xlsx = require('xlsx'); var xls = xlsx.readFileSync(path.join(__dirname, 'registry.xls')); var ods = xlsx.readFileSync(path.join(__dirname, 'ffc.ods')); if (xls.Strings.length > 50 && ods.SheetNames.length > 0) { console.log('ok'); } ================================================ FILE: test/test-79-npm/xml2js/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/xml2js/xml2js.js ================================================ 'use strict'; var parse = require('xml2js').parseString; var xml = 'Hello xml2js!'; parse(xml, function (error, result) { if (error) throw error; if (result.root === 'Hello xml2js!') { console.log('ok'); } }); ================================================ FILE: test/test-79-npm/yargs/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/yargs/yargs.js ================================================ 'use strict'; var yargs = require('yargs'); var argv = yargs.argv; if (argv.$0) { console.log('ok'); } ================================================ FILE: test/test-79-npm/zeromq/package.json ================================================ { "private": true } ================================================ FILE: test/test-79-npm/zeromq/zeromq.js ================================================ 'use strict'; var zeromq = require('zeromq'); if (zeromq.version) { console.log('ok'); } ================================================ FILE: test/test-79-npm/zeromq/zeromq.meta.js ================================================ 'use strict'; const home = require('../home.js'); module.exports = function (stamp) { return { allow: home(stamp), deployFilesFrom: ['zeromq'], }; }; ================================================ FILE: test/test-80-compression/.gitignore ================================================ output-* ================================================ FILE: test/test-80-compression/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); /* eslint-disable no-unused-vars */ const input = 'test-x.js'; const target = 'host'; const ext = process.platform === 'win32' ? '.exe' : ''; const outputRef = 'output-empty' + ext; const outputNone = 'output-None' + ext; const outputGZip = 'output-Brotli' + ext; const outputBrotli = 'output-GZip' + ext; const outputBrotliDebug = 'output-debug' + ext; const inspect = ['ignore', 'ignore', 'pipe']; console.log(' compiling empty '); const logPkg0 = utils.pkg.sync( [ '--target', target, '--compress', 'None', '--output', outputRef, './test-empty.js', ], { expect: 0 } ); const sizeReference = fs.statSync(outputRef).size; function pkgCompress(compressMode, output) { console.log(` compiling compression ${compressMode} `); const logPkg1 = utils.pkg.sync( ['--target', target, '--compress', compressMode, '--output', output, input], { stdio: inspect, expect: 0 } ); // check that produced executable is running and produce the expected output. const log = utils.spawn.sync(path.join(__dirname, output), [], { cwd: __dirname, expect: 0, }); assert(log === '42\n'); return fs.statSync(output).size; } const sizeNoneFull = pkgCompress('None', outputNone); const sizeGZipFull = pkgCompress('GZip', outputGZip); const sizeBrotliFull = pkgCompress('Brotli', outputBrotli); const sizeNone = sizeNoneFull - sizeReference; const sizeBrotli = sizeBrotliFull - sizeReference; const sizeGZip = sizeGZipFull - sizeReference; console.log(' compiling compression Brotli + debug'); const logPkg4 = utils.pkg.sync( [ '--target', target, '--debug', '--compress', 'Brotli', '--output', outputBrotliDebug, input, ], { expect: 0 } ); console.log('node.exe size =', sizeReference); console.log('virtual file system'); console.log('No compression = ', sizeNone - sizeReference); console.log( ' Δ GZip = ', sizeGZip - sizeNone, '(', (((sizeGZip - sizeNone) / sizeNone) * 100).toFixed(0), '%)' ); console.log( ' Δ Brotli = ', sizeBrotli - sizeNone, '(', (((sizeBrotli - sizeNone) / sizeNone) * 100).toFixed(0), '%)' ); assert(sizeNone > sizeGZip); assert(sizeGZip > sizeBrotli); const logPkg5 = utils.pkg.sync( ['--target', target, '--compress', 'Crap', '--output', outputBrotli, input], { expect: 2 } ); // xx console.log(logPkg4); assert(logPkg5.match(/Invalid compression algorithm/g)); utils.vacuum.sync(outputRef); utils.vacuum.sync(outputNone); utils.vacuum.sync(outputBrotli); utils.vacuum.sync(outputGZip); utils.vacuum.sync(outputBrotliDebug); ================================================ FILE: test/test-80-compression/test-empty.js ================================================ /** empty */ ================================================ FILE: test/test-80-compression/test-x.js ================================================ 'use strict'; /* eslint-disable no-unused-vars */ const m = require('minimist'); const c = require('chalk'); const loremIpsum = 'Unus audio pluribus sibi quibusdam amicitias habere qua satis molestum sapientes molestum est vel frui non pluribus nimias possit quam esse sollicitum adducas persequantur esse audio nihil sollicitum laxissimas enim rerum vel non ad tamquam habitos implicari placuisse quibusdam nihil.'; const loremIpsum2 = 'Semper praetorio satisfaceret semper sit militem ut ipse ordinarias ad atque sit ire in ad sit ut more trusus dignitates more compellebatur ultimum praefectus discrimen et in ut tempestate et dignitates impedita convectio in est inopia ad alioqui et ob.'; console.log(42 || loremIpsum2 || loremIpsum2); ================================================ FILE: test/test-80-compression-node-opcua/.gitignore ================================================ node_modules ================================================ FILE: test/test-80-compression-node-opcua/main.js ================================================ #!/usr/bin/env node 'use strict'; /* * A test with a large number of modules with symlinks * (installed with npm) and compress * */ const fs = require('fs'); const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); if (utils.shouldSkipPnpm()) { return; } // remove any possible left-over utils.vacuum.sync('./node_modules'); utils.vacuum.sync('./pnpm-lock.yaml'); // launch `pnpm install` const pnpmlog = utils.spawn.sync( path.join( path.dirname(process.argv[0]), 'npx' + (process.platform === 'win32' ? '.cmd' : '') ), ['pnpm', 'install'], { cwd: path.dirname(__filename), expect: 0 } ); console.log('pnpm log :', pnpmlog); // verify that we have the .pnpm folder and a symlinks module in node_modules assert(fs.lstatSync(path.join(__dirname, 'node_modules/.pnpm')).isDirectory()); assert( fs .lstatSync(path.join(__dirname, 'node_modules/node-opcua-address-space')) .isSymbolicLink() ); /* eslint-disable no-unused-vars */ const input = 'package.json'; const target = process.argv[2] || 'host'; const ext = process.platform === 'win32' ? '.exe' : ''; const outputRef = 'test-output-empty' + ext; const outputNone = 'test-output-None' + ext; const outputGZip = 'test-output-GZip' + ext; const outputBrotli = 'test-output-Brotli' + ext; const outputBrotliDebug = 'test-output-Brotli-debug' + ext; const inspect = ['ignore', 'ignore', 'pipe']; console.log(' compiling empty '); const logPkg0 = utils.pkg.sync( [ '--target', target, '--compress', 'None', '--output', outputRef, './test-empty.js', ], { stdio: inspect, expect: 0 } ); const sizeReference = fs.statSync(outputRef).size; function pkgCompress(compressMode, output) { console.log(` compiling compression ${compressMode} `); const logPkg1 = utils.pkg.sync( ['--target', target, '--compress', compressMode, '--output', output, input], { stdio: inspect, expect: 0 } ); // check that produced executable is running and produce the expected output. const log = utils.spawn.sync(path.join(__dirname, output), [], { cwd: __dirname, expect: 0, }); assert(log === '42\n'); return fs.statSync(output).size; } const sizeNoneFull = pkgCompress('None', outputNone); const sizeGZipFull = pkgCompress('GZip', outputGZip); const sizeBrotliFull = pkgCompress('Brotli', outputBrotli); const sizeNone = sizeNoneFull - sizeReference; const sizeBrotli = sizeBrotliFull - sizeReference; const sizeGZip = sizeGZipFull - sizeReference; console.log('empty = ', sizeReference); console.log('no compression = ', sizeNoneFull, sizeNone); console.log('Brotli = ', sizeBrotliFull, sizeBrotli); console.log('GZip = ', sizeGZipFull, sizeGZip); console.log( ' Δ GZip = ', sizeGZip - sizeNone, '(', (((sizeGZip - sizeNone) / sizeNone) * 100).toFixed(0), '%)' ); console.log( ' Δ Brotli = ', sizeBrotli - sizeNone, '(', (((sizeBrotli - sizeNone) / sizeNone) * 100).toFixed(0), '%)' ); assert(sizeNone > sizeGZip); assert(sizeGZip > sizeBrotli); const logPkg5 = utils.pkg.sync( ['--target', target, '--compress', 'Crap', '--output', outputBrotli, input], { expect: 2 } ); // xx console.log(logPkg4); assert(logPkg5.match(/Invalid compression algorithm/g)); utils.vacuum.sync(outputRef); utils.vacuum.sync(outputNone); utils.vacuum.sync(outputBrotli); utils.vacuum.sync(outputGZip); utils.vacuum.sync(outputBrotliDebug); utils.vacuum.sync('node_modules'); utils.vacuum.sync('./pnpm-lock.yaml'); console.log('OK'); ================================================ FILE: test/test-80-compression-node-opcua/package.json ================================================ { "name": "test-12-compression", "version": "1.0.0", "description": "", "main": "test-x.js", "scripts": { "preinstall": "npx only-allow pnpm", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "node-opcua-address-space": "^2.36.0", "node-opcua-crypto": "^1.7.1", "node-opcua-nodesets": "^2.36.0" }, "bin": "test-x.js", "pkg": { "assets": [ "./node_modules/node-opcua-nodesets/nodesets/*.xml" ] } } ================================================ FILE: test/test-80-compression-node-opcua/test-empty.js ================================================ /***/ ================================================ FILE: test/test-80-compression-node-opcua/test-x.js ================================================ 'use strict'; const { AddressSpace } = require('node-opcua-address-space'); const { generateAddressSpace } = require('node-opcua-address-space/nodeJS'); const { nodesets } = require('node-opcua-nodesets'); (async () => { const addressSpace = AddressSpace.create({}); await generateAddressSpace(addressSpace, [nodesets.standard]); console.log('42'); })(); ================================================ FILE: test/test-80-compression-node-opcua/test-y.js ================================================ 'use strict'; const fs = require('fs'); const { nodesets } = require('node-opcua-nodesets'); const a = fs.readFileSync(nodesets.adi); console.log(a.length); ================================================ FILE: test/test-80-compression-various-file-access/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); /* eslint-disable no-unused-vars */ const target = process.argv[2] || 'host'; const ext = process.platform === 'win32' ? '.exe' : ''; const output = 'output' + ext; async function runTest(input) { const output_none = output + '_' + path.parse(input).name; const output_gzip = 'gzip_' + output_none; const logPkgNone = utils.pkg.sync( ['--target', target, '--compress', 'None', '--output', output_none, input], { expect: 0 } ); const logPkgGZip = utils.pkg.sync( ['--target', target, '--compress', 'GZIP', '--output', output_gzip, input], { expect: 0 } ); // ----------------------------------------------------------------------- // Execute program outside pjg const logRef = utils.spawn.sync('node', [path.join(__dirname, input)], { cwd: __dirname, expect: 0, }); const logNone = utils.spawn.sync(path.join(__dirname, output_none), [], { cwd: __dirname, expect: 0, }); const logGZip = utils.spawn.sync(path.join(__dirname, output_gzip), [], { cwd: __dirname, expect: 0, }); if (logRef !== logNone) { console.log( " uncompress pkg doesn't produce same result as running with node" ); } if (logRef !== logGZip) { console.log( " GZIP compress pkg doesn't produce same result as running with node" ); } if (logRef !== logNone || logRef !== logGZip) { console.log(' Reference:'); console.log(logRef); console.log(' Uncompress:'); console.log(logNone); console.log(' GZIPed:'); console.log(logGZip); console.log('------------ ERROR'); process.exit(1000); } utils.vacuum.sync(output); utils.vacuum.sync('gzip_' + output); } const input1 = 'test.js'; console.log(' now testing with fs callback'); runTest(input1); console.log(' now testing with fs.promises'); const input2 = 'test_with_new_fs_promises.js'; runTest(input2); console.log('Done'); process.exit(0); ================================================ FILE: test/test-80-compression-various-file-access/myfile.txt ================================================ 123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ================================================ FILE: test/test-80-compression-various-file-access/package.json ================================================ { "name": "test-12-compression-with-asset", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" } ================================================ FILE: test/test-80-compression-various-file-access/test.js ================================================ 'use strict'; const path = require('path'); const fs = require('fs'); const file = path.join(__dirname, 'myfile.txt'); const binaryFile = path.join(__dirname, 'myfile.bin'); function withReadFileSync() { const wholeFile = fs.readFileSync(file, 'ascii'); console.log(wholeFile); console.log('withReadFileSync done !'); } async function withDirectAccess() { try { const buffer = Buffer.alloc(1000); const fd = fs.openSync(file); fs.readSync(fd, buffer, 0, buffer.length, 10); fs.closeSync(fd); console.log(buffer.toString('ascii')); } catch (err) { console.log(err.message); console.log(err); } console.log('withDirectAccess ! done!'); } async function withReadStream() { const stream = fs.createReadStream( file /* { start: 10, encoding: "ascii" } */ ); stream.on('data', (data) => { console.log(data.toString()); }); await new Promise((resolve) => { stream.on('end', resolve); }); console.log('withReadStream done !'); } async function withReadStream2() { const stream = fs.createReadStream(file, { start: 10, encoding: 'ascii' }); stream.on('data', (data) => { console.log(data.toString()); }); await new Promise((resolve) => { stream.on('end', resolve); }); console.log('withReadStream done !'); } async function readbinaryFile() { const fd = fs.openSync(binaryFile, 'r'); const buf = Buffer.alloc(25); fs.readSync(fd, buf, 0, buf.length, 10); fs.closeSync(fd); console.log(buf.toString('hex')); console.log('readbinaryFile done !'); } async function readbinaryFileWithStream() { const stream = fs.createReadStream(binaryFile, { encoding: 'hex', start: 10, end: 34, }); stream.on('data', (data) => { console.log(data.toString()); }); await new Promise((resolve) => { stream.on('end', resolve); }); console.log('readbinaryFileWithStream done !'); } (async () => { console.log('--------------- withReadFileSync'); await withReadFileSync(); console.log('--------------- withReadStream'); await withReadStream(); console.log('--------------- withDirectAccess'); await withDirectAccess(); console.log('--------------- withReadStream2'); await withReadStream2(); console.log('--------------- readbinaryFile'); await readbinaryFile(); console.log('--------------- readbinaryFileWithStream'); await readbinaryFileWithStream(); })(); ================================================ FILE: test/test-80-compression-various-file-access/test_with_new_fs_promises.js ================================================ 'use strict'; const path = require('path'); let fs_promises; const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10); if (MAJOR_VERSION >= 14) { // only work with nodeJs >= 14.0 fs_promises = require('fs/promises'); } else { fs_promises = require('fs').promises; } // note: this file will be packed in the virtual file system by PKG const file = path.join(__dirname, 'myfile.txt'); async function withPromises() { // note : the fs.promise API is quite changing between node12/node14 etc... let fd; try { fd = await fs_promises.open(file, 'r'); // Do something with the file const buffer = Buffer.alloc(1000); if (MAJOR_VERSION >= 14) { const { bytesRead } = await fd.read(buffer, 0, buffer.length, 10); if (process.env.DEBUG) { console.log('bytesRead = ', bytesRead); } } else { await fd.read(buffer, 0, buffer.length, 10); } console.log(buffer.toString()); } catch (err) { console.log('ERRR =', err.message); console.log(err); } finally { if (fd) { await fd.close(); } } console.log('withPromises ! done!'); } async function withPromisesReadFile() { try { const content = await fs_promises.readFile(file, { encoding: 'ascii' }); console.log(content); } catch (err) { console.log('ERRR =', err.message); console.log(err); } console.log('withPromisesReadFile ! done!'); } async function withPromiseReadDir() { const thisFile = path.basename(__filename); try { const folder = path.join(__dirname, '/'); const files = await fs_promises.readdir(folder); console.log( files.findIndex((x) => x === thisFile) >= 0 ? 'Success' : 'Failure' ); } catch (err) { console.log(err.message); } console.log('withPromiseReadDir ! done!'); } (async () => { await withPromises(); await withPromisesReadFile(); await withPromiseReadDir(); console.log(42); })(); ================================================ FILE: test/test-99-#1120-mkdir-mountpoints/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let right; utils.mkdirp.sync(path.dirname(output)); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(right, 'hello.txt\n'); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-99-#1120-mkdir-mountpoints/test-x-index.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); var myDirectory = path.dirname(process.execPath); process.pkg.mount( path.join(__dirname, 'plugins-D-ext'), path.join(myDirectory, 'plugins-D-ext') ); fs.mkdirSync('./plugins-D-ext/'); fs.writeFileSync('./plugins-D-ext/hello.txt', 'hello world!'); console.log( fs.readdirSync(path.join(__dirname, './plugins-D-ext/')).join('\n') ); ================================================ FILE: test/test-99-#1121-regexp-mountpoints/main.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; let right; utils.mkdirp.sync(path.dirname(output)); utils.mkdirp.sync(path.join(path.dirname(output), 'plugins-D-ext')); fs.writeFileSync( path.join(path.dirname(output), 'plugins-D-ext/test-y-require-D.js'), fs.readFileSync('./plugins-D-ext/test-y-require-D.js') ); utils.pkg.sync(['--target', target, '--output', output, input]); right = utils.spawn.sync('./' + path.basename(output), [], { cwd: path.dirname(output), }); assert.strictEqual(right, 'I am D\ntest-x-index.js\n'); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-99-#1121-regexp-mountpoints/plugins-D-ext/test-y-require-D.js ================================================ 'use strict'; var assert = require('assert'); if (__dirname.indexOf('snapshot') < 0) { console.log(__dirname); assert(false); } console.log('I am D'); ================================================ FILE: test/test-99-#1121-regexp-mountpoints/test-x-index.js ================================================ 'use strict'; var fs = require('fs'); var path = require('path'); var myDirectory = path.dirname(process.execPath); process.pkg.mount( /^(.*)regexp_mountpoint_test(.*)$/, function (match, group1, group2) { return path.join(myDirectory, 'plugins-D-ext', group2); } ); require('./regexp_mountpoint_test/test-y-require-D.js'.slice()); console.log(fs.readdirSync(__dirname).join('\n')); ================================================ FILE: test/test-99-#1130/.gitignore ================================================ run-time ================================================ FILE: test/test-99-#1130/files/a.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: test/test-99-#1130/files/b.js ================================================ 'use strict'; module.exports = {}; ================================================ FILE: test/test-99-#1130/main.js ================================================ #!/usr/bin/env node // Thanks to @roberttod // https://github.com/vercel/pkg/blob/59b1afdb39613777150c17f77b45595864ba072e/test/test-1103-readdirsync-withfiletypes/main.js 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './read.js'; const output = './run-time/test-output.exe'; utils.mkdirp.sync(path.dirname(output)); utils.pkg.sync(['--target', target, '--output', output, '.']); let left, right; left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); right = utils.spawn.sync(output, [], { cwd: path.dirname(input), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-99-#1130/package.json ================================================ { "bin": "read.js", "pkg": { "scripts": "files/*.js" } } ================================================ FILE: test/test-99-#1130/read.js ================================================ 'use strict'; // Thanks to @roberttod // https://github.com/vercel/pkg/blob/59b1afdb39613777150c17f77b45595864ba072e/test/test-1103-readdirsync-withfiletypes/read.js const fs = require('fs'); const path = require('path'); console.log('Starting sync read'); console.log( serializeFiles( fs.readdirSync(path.join(__dirname, 'files'), { withFileTypes: true }) ) ); console.log('Finishing sync read'); console.log('Starting async read'); fs.readdir( path.join(__dirname, 'files'), { withFileTypes: true }, (_err, files) => { console.log(serializeFiles(files)); console.log('Finishing async read'); } ); function serializeFiles(files) { return files.map((file) => `name: ${file.name}, isFile: ${file.isFile()}`); } ================================================ FILE: test/test-99-#1135/.gitignore ================================================ package-lock.json node_modules ================================================ FILE: test/test-99-#1135/index.js ================================================ 'use strict'; /* eslint-disable no-unused-vars */ var canvas = require('canvas'); console.log('42'); ================================================ FILE: test/test-99-#1135/main.js ================================================ #!/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); 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'); ================================================ FILE: test/test-99-#1135/package.json ================================================ { "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" } } ================================================ FILE: test/test-99-#1191/.gitignore ================================================ output* test.sqlite package-lock* ================================================ FILE: test/test-99-#1191/index.js ================================================ 'use strict'; require('better-sqlite3')('test.sqlite'); console.log('42'); ================================================ FILE: test/test-99-#1191/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); /* eslint-disable no-unused-vars */ const target = process.argv[2] || 'host'; if (target !== 'host') { console.log('skipping test, as target=', target); // skipping test, this test would require recompiling for a different node version return; } const ext = process.platform === 'win32' ? '.exe' : ''; const output1 = './output1' + ext; const output2 = './output2' + ext; const input = './index.js'; // remove any possible left-over utils.vacuum.sync('./node_modules'); const version = utils.exec.sync('node --version'); console.log('node version = ', version); // launch `yarn` const yarnlog = utils.exec.sync('yarn'); console.log('yarn log :', yarnlog); // ----------------------------------------------------------------------- // Execute programm outside pjg const logRef = utils.spawn.sync('node', [path.join(__dirname, input)], { cwd: __dirname, expect: 0, }); if (logRef.replace(/\r|\n/g, '') !== '42') { console.log(`expecting 42 but got ${logRef}`); process.exit(1); } function doTestWithCompression() { console.log('doTestWithCompression'); utils.pkg.sync( ['--compress', 'Brotli', '--target', target, '--output', output1, input], { // expect: 0, } ); const log = utils.spawn.sync(path.join(__dirname, output1), [], { cwd: __dirname, // expect: 0, stdio: ['inherit', 'pipe', 'pipe'], }); return log; } function doTestNoCompression() { console.log('doTestNoCompression'); utils.pkg.sync(['--target', target, '--output', output2, input], { // expect: 0, }); const log = utils.spawn.sync(path.join(__dirname, output2), [], { cwd: __dirname, expect: 0, stdio: ['inherit', 'pipe', 'pipe'], }); return log; } const logNoCompression = doTestNoCompression(); if (logNoCompression.stderr !== '') { console.log('NO COMPRESSION: expecting no error'); console.log('but got =', logNoCompression.stderr); process.exit(1); } const logWithCompression = doTestWithCompression(); if (logWithCompression.stderr !== '') { console.log('NO COMPRESSION: expecting no error'); console.log('but got =', logWithCompression.stderr); process.exit(1); } // now with compress utils.vacuum.sync(output1); utils.vacuum.sync(output2); utils.vacuum.sync('node_modules'); utils.vacuum.sync('package-lock.json'); utils.vacuum.sync('test.sqlite'); console.log('Done'); ================================================ FILE: test/test-99-#1191/package.json ================================================ { "name": "test-1191", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "better-sqlite3": "^7.4.0" } } ================================================ FILE: test/test-99-#1192/.gitignore ================================================ dist/ ================================================ FILE: test/test-99-#1192/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); /* eslint-disable no-unused-vars */ const target = process.argv[2] || 'host'; if (target !== 'host') { console.log('skipping test, as target=', target); // skipping test, this test would require recompiling for a different node version return; } const doDebug = false; const ext = process.platform === 'win32' ? '.exe' : ''; const output = './output' + ext; const input = './package.json'; // remove any possible left-over // utils.vacuum.sync('./node_modules'); const version = utils.exec.sync('node --version'); if (doDebug) { console.log('node version = ', version); } // launch `yarn` const yarnlog = utils.exec.sync('yarn'); if (doDebug) { console.log('yarn log :', yarnlog); } // ----------------------------------------------------------------------- // Execute program outside pjg const logRef = utils.spawn.sync( 'node', [path.join(__dirname, 'src/index.js')], { cwd: __dirname, expect: 0, stdio: ['inherit', 'pipe', 'pipe'], } ); function runTest(doCompress) { const options = [ '--target', target, '--output', output, input, ...doCompress, ]; utils.pkg.sync(options, { expect: 0, }); const log = utils.spawn.sync(path.join(__dirname, output), [], { cwd: __dirname, expect: 0, stdio: ['inherit', 'pipe', 'pipe'], }); if (doDebug) { console.log(logRef.stdout); } if (logRef.stdout !== log.stdout) { console.log('expecting', logRef.stdout); console.log('but got =', log.stdout); process.exit(1); } if (logRef.stderr !== log.stderr) { console.log('expecting', logRef.stderr); console.log('but got =', log.stderr); process.exit(1); } } runTest([]); runTest(['--compress', 'GZip']); runTest(['--compress', 'Brotli']); utils.vacuum.sync(output); // utils.vacuum.sync('node_modules'); utils.vacuum.sync('package-lock.json'); console.log('Done'); ================================================ FILE: test/test-99-#1192/package.json ================================================ { "name": "pkg-express", "version": "1.0.0", "description": "Illustrates issue between pkg 5.2.X and express (works with with pkg pre 5.2.X).", "repository": "", "main": "src/index.js", "bin": "src/index.js", "license": "MIT", "scripts": { "postinstall": "npm run make", "start": "node .", "make": "pkg . -o ./dist/pkg-express.exe" }, "dependencies": { "express": "^4.17.1", "pug": "^3.0.2" }, "devDependencies": { "pkg": "5.2.1" }, "pkg": { "assets": "./public/views/*.pug" } } ================================================ FILE: test/test-99-#1192/public/views/index.pug ================================================ html head title Hello World! body p Hello World! p äöüß m² and ☺ p 🤡🤩🦄 ================================================ FILE: test/test-99-#1192/src/index.js ================================================ 'use strict'; const http = require('http'); const path = require('path'); const express = require('express'); // Express app const app = express(); // Express views app.set('views', path.join(__dirname, '../public/views')); // Use pug as Express view engine app.set('view engine', 'pug'); // Match all routes app.use('*', (_req, res) => { res.render('index.pug'); }); // Start HTTP server const listener = http.createServer(app).listen(8080, () => { console.info('Server started, listening on %d', listener.address().port); }); // ------------------ now query he server (async () => { const options = { hostname: '127.0.0.1', path: '/', method: 'GET', port: 8080, }; const req = http.request(options, (res) => { console.log(`statusCode: ${res.statusCode}`); res.on('data', (d) => { process.stdout.write(d); }); }); req.on('error', (error) => { console.error(error); process.exit(1); }); req.on('close', () => { process.exit(0); }); req.end(); })(); ================================================ FILE: test/test-99-#1207/.gitignore ================================================ *.exe ================================================ FILE: test/test-99-#1207/index.js ================================================ 'use strict'; console.log(process.env.DEBUG_PKG || 42); ================================================ FILE: test/test-99-#1207/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); const path = require('path'); assert(!module.parent); assert(__dirname === process.cwd()); if (process.platform !== 'win32') { console.log('Skipping this test on non windows platform'); return 0; } const input = 'H:\\index.js'; const output = 'H:\\index.exe'; // mount a H drive const thisFolder = __dirname; try { utils.exec.sync(`subst H: /D`); } catch (err) { /* */ } utils.exec.sync(`subst H: ${thisFolder}`); // build from the alternate drive utils.pkg.sync(['--debug', '--target', 'host', '--output', output, input], { cwd: 'H:\\', // stdio: 'inherit' }); // check that produced executable is running and produce the expected output. // when run tom the same file it has been built on. const log = utils.spawn.sync(output, [], { cwd: path.dirname(output), expect: 0, }); assert(log === '42\n'); // check that produced executable is running and produce the expected output. const logRef = utils.spawn.sync(output, [], { cwd: path.dirname(output), env: { DEBUG_PKG: 42 }, expect: 0, }); if (!logRef.match(/42\n$/m)) { console.log(logRef); process.exit(1); } // running on C while H: drive is here const alternateOutput = path.resolve('.\\index.exe'); console.log('alternateOutput', alternateOutput); const log1 = utils.spawn.sync(alternateOutput, [], { cwd: path.dirname(alternateOutput), env: { DEBUG_PKG: 42 }, expect: 0, }); assert(log1 === logRef); // running on C while H: drive is not here anymore utils.exec.sync(`subst H: /D`); const log2 = utils.spawn.sync(alternateOutput, [], { cwd: path.dirname(alternateOutput), env: { DEBUG_PKG: 42 }, expect: 0, }); assert(log2 === logRef); utils.vacuum.sync(output); ================================================ FILE: test/test-99-#1505/.gitignore ================================================ run-time ================================================ FILE: test/test-99-#1505/files/test.txt ================================================ ================================================ FILE: test/test-99-#1505/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './stat.js'; const output = './run-time/test-output.exe'; utils.mkdirp.sync(path.dirname(output)); utils.pkg.sync(['--target', target, '--output', output, '.']); let left, right; left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); right = utils.spawn.sync(output, [], { cwd: path.dirname(input), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-99-#1505/package.json ================================================ { "bin": "stat.js", "pkg": { "scripts": "files/*" } } ================================================ FILE: test/test-99-#1505/stat.js ================================================ 'use strict'; const path = require('path'); const util = require('util'); const fs = require('fs'); let fsp; try { fsp = require('fs/promises'); } catch (_) { fsp = require('fs').promises; } const filePath = path.join(__dirname, 'files/test.txt'); async function test() { for (const key of ['stat', 'lstat']) { console.log(key, 'callback'); const promisified = util.promisify(fs[key]); console.log(serialize(await promisified(filePath))); console.log(key, 'promise'); console.log(serialize(await fsp[key](filePath))); } } function serialize(result) { if (!result) return null; return `${result.size} ${result.mode}`; } test(); ================================================ FILE: test/test-99-#1861/index.js ================================================ #!/usr/bin/env node 'use strict'; const { spawn } = require('child_process'); const { argv } = process; if (argv.length <= 2) { console.log('stop'); process.exit(); } console.log('launch'); const cp = spawn('cmd.exe', ['/C', 'launch.bat'], { shell: true }); cp.stdout.on('data', (output) => console.log(output.toString())); cp.on('close', process.exit); ================================================ FILE: test/test-99-#1861/launch.bat ================================================ @echo off index.exe exit ================================================ FILE: test/test-99-#1861/main.js ================================================ #!/usr/bin/env node 'use strict'; const assert = require('assert'); const utils = require('../utils.js'); const path = require('path'); assert(!module.parent); assert(__dirname === process.cwd()); if (process.platform !== 'win32') { console.log('Skipping this test on non-windows platform.'); return 0; } const input = path.join(__dirname, '/index.js'); const output = path.join(__dirname, '/index.exe'); // build executable utils.pkg.sync(['--debug', '--target', 'host', '--output', output, input]); const log = utils.spawn.sync(output, ['launch'], { expect: 0 }); assert(log.includes('launch')); assert(log.includes('stop')); utils.vacuum.sync(output); ================================================ FILE: test/test-99-#420-copy-from-snapshot/.gitignore ================================================ output sync.json async.json ================================================ FILE: test/test-99-#420-copy-from-snapshot/copy.js ================================================ #!/usr/bin/env node 'use strict'; const fs = require('fs'); const path = require('path'); const testPath = path.resolve(__dirname, 'input/test.json'); console.log(fs.readFileSync(testPath, 'utf8')); const syncPath = path.resolve(process.cwd(), 'output/sync.json'); fs.copyFileSync(testPath, syncPath); console.log(fs.readFileSync(syncPath, 'utf8')); const asyncPath = path.resolve(process.cwd(), 'output/async.json'); fs.copyFile(testPath, asyncPath, (err) => { if (err) throw err; console.log(fs.readFileSync(asyncPath, 'utf8')); }); ================================================ FILE: test/test-99-#420-copy-from-snapshot/input/test.json ================================================ { "key": "value" } ================================================ FILE: test/test-99-#420-copy-from-snapshot/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './copy.js'; const output = './output/test-output.exe'; utils.mkdirp.sync(path.dirname(output)); utils.pkg.sync(['--target', target, '--output', output, '.']); let left, right; left = utils.spawn.sync('node', [path.basename(input)], { cwd: path.dirname(input), }); right = utils.spawn.sync(output, [], { cwd: path.dirname(input), }); assert.strictEqual(left, right); utils.vacuum.sync(path.dirname(output)); utils.vacuum.sync(path.join(__dirname, '/*sync.json')); ================================================ FILE: test/test-99-#420-copy-from-snapshot/package.json ================================================ { "bin": "copy.js", "pkg": { "assets": [ "input/**/*" ] } } ================================================ FILE: test/test-99-#775/a.js ================================================ 'use strict'; console.log('Starting a'); // note : worker_threads in only valid for nodejs >= 12.0 const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10); if (MAJOR_VERSION < 12) { return; } const { Worker } = require('worker_threads'); // eslint-disable-next-line no-new new Worker('./b.js'); console.log('Finishing a'); ================================================ FILE: test/test-99-#775/b.js ================================================ 'use strict'; console.log('Starting b'); console.log('Finishing b'); ================================================ FILE: test/test-99-#775/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); // note : worker_threads in only valid for nodejs >=12.0 const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10); if (MAJOR_VERSION < 12) { console.log('Ignoring test '); return; } /* eslint-disable no-unused-vars */ const input = 'package.json'; const target = 'host'; const ext = process.platform === 'win32' ? '.exe' : ''; const output = 'output' + ext; const inspect = ['ignore', 'ignore', 'pipe']; const logPkg1 = utils.pkg.sync( ['--target', target, '--debug', '--output', output, input], { expect: 0 } ); const log1 = utils.spawn.sync(path.join(__dirname, output), [], { cwd: __dirname, expect: 0, }); assert.strictEqual( log1, `Starting a Finishing a Starting b Finishing b ` ); const logPkg2 = utils.pkg.sync( ['--target', target, '--debug', '--output', output, 'a.js'], { expect: 0 } ); const log2 = utils.spawn.sync(path.join(__dirname, output), [], { cwd: __dirname, expect: 0, }); assert.strictEqual( log2, `Starting a Finishing a Starting b Finishing b ` ); utils.vacuum.sync(output); ================================================ FILE: test/test-99-#775/package.json ================================================ { "name": "a", "version": "0.1.0", "description": "proof", "bin": "a.js", "license": "UNLICENSED", "devDependencies": { "pkg": "^4.4.0" }, "pkg": { "scripts": [ "a.js", "b.js" ] } } ================================================ FILE: test/test-99-#938-withfiletypes/.gitignore ================================================ run-time ================================================ FILE: test/test-99-#938-withfiletypes/main.js ================================================ #!/usr/bin/env node 'use strict'; const path = require('path'); const assert = require('assert'); const utils = require('../utils.js'); assert(!module.parent); assert(__dirname === process.cwd()); const target = process.argv[2] || 'host'; const input = './read.js'; const output = './run-time/test-output.exe'; utils.mkdirp.sync(path.dirname(output)); utils.pkg.sync(['--target', target, '--output', output, '.']); let right; right = utils.spawn.sync(output, [], { cwd: path.dirname(input), }); assert.strictEqual('ok\n', right); utils.vacuum.sync(path.dirname(output)); ================================================ FILE: test/test-99-#938-withfiletypes/package.json ================================================ { "bin": "read.js" } ================================================ FILE: test/test-99-#938-withfiletypes/read.js ================================================ 'use strict'; const fs = require('fs'); function isLastEntryString(files) { const last = files[files.length - 1]; return typeof last === 'string'; } function isLastEntryDirent(files) { const last = files[files.length - 1]; return ( typeof last === 'object' && typeof last.name === 'string' && typeof last.type === 'number' ); } // readdir root and verify that last pushed entry (snapshot in the binary) has the expected type // expect Dirent array const a = fs.readdirSync('/', { encoding: 'utf8', withFileTypes: true }); fs.readdir('/', { encoding: 'utf8', withFileTypes: true }, (err, b) => { if (err) throw err; if (isLastEntryDirent(a) && isLastEntryDirent(b)) { // expect string array const c = fs.readdirSync('/', { encoding: 'utf8', withFileTypes: false }); fs.readdir('/', { encoding: 'utf8', withFileTypes: false }, (err_, d) => { if (err_) throw err_; if (isLastEntryString(c) && isLastEntryString(d)) { console.log('ok'); } }); } }); ================================================ FILE: test/test.js ================================================ #!/usr/bin/env node 'use strict'; const chalk = require('chalk'); const globby = require('globby'); const path = require('path'); const utils = require('./utils.js'); const host = 'node' + process.version.match(/^v(\d+)/)[1]; let target = process.argv[2] || 'host'; if (target === 'host') target = host; // note to developer , you can use // FLAVOR=test-1191 npm test // if you only want to run all combination of this specific test case // ( the env variable FLAVOR takes precedence over the second argument passed to this main.js file) const flavor = process.env.FLAVOR || process.argv[3] || 'all'; console.log(''); console.log('*************************************'); console.log(target + ' ' + flavor); console.log('*************************************'); console.log(''); if (process.env.CI) { if ( target === 'node0' || target === 'node4' || target === 'node6' || target === 'node7' || target === 'node9' || target === 'node11' || target === 'node13' || target === 'node15' ) { console.log(target + ' is skipped in CI!'); console.log(''); process.exit(); } } function joinAndForward(d) { let r = path.join(__dirname, d); if (process.platform === 'win32') r = r.replace(/\\/g, '/'); return r; } const list = []; if (flavor.match(/^test/)) { list.push(joinAndForward(`${flavor}/main.js`)); } else if (flavor === 'only-npm') { list.push(joinAndForward('test-79-npm/main.js')); } else { list.push(joinAndForward('**/main.js')); if (flavor === 'no-npm') { list.push('!' + joinAndForward('test-42-fetch-all')); list.push('!' + joinAndForward('test-46-multi-arch')); list.push('!' + joinAndForward('test-46-multi-arch-2')); list.push('!' + joinAndForward('test-79-npm')); } } const files = globby.sync(list); files.sort().some(function (file) { file = path.resolve(file); try { utils.spawn.sync('node', [path.basename(file), target], { cwd: path.dirname(file), stdio: 'inherit', }); } catch (error) { console.log(); console.log(`> ${chalk.red('Error!')} ${error.message}`); console.log(`> ${chalk.red('Error!')} ${file} FAILED (in ${target})`); process.exit(2); } console.log(file, 'ok'); }); ================================================ FILE: test/utils.js ================================================ 'use strict'; const assert = require('assert'); const path = require('path'); const mkdirp = require('mkdirp'); const rimraf = require('rimraf'); const globby = require('globby'); const { execSync } = require('child_process'); const { spawnSync } = require('child_process'); const { existsSync } = require('fs'); const stableStringify = require('json-stable-stringify'); module.exports.mkdirp = mkdirp; module.exports.pause = function (seconds) { spawnSync('ping', [ '127.0.0.1', process.platform === 'win32' ? '-n' : '-c', (seconds + 1).toString(), ]); }; module.exports.vacuum = function () { throw new Error('Async vacuum not implemented'); }; module.exports.vacuum.sync = function (p) { const limit = 5; let hasError; for (let i = 0; i < limit; i += 1) { hasError = null; try { rimraf.sync(p); } catch (error) { hasError = error; } if (!hasError) break; if (i < limit - 1) { module.exports.pause(5); } } if (hasError) { throw hasError; } }; module.exports.exec = function () { throw new Error('Async exec not implemented'); }; module.exports.exec.sync = function (command, opts) { const child = execSync(command, opts); return (child || '').toString(); }; module.exports.spawn = function () { throw new Error('Async spawn not implemented'); }; module.exports.spawn.sync = function (command, args, opts) { if (!opts) opts = {}; opts = Object.assign({}, opts); // change own copy const d = opts.stdio; if (!d) { opts.stdio = ['pipe', 'pipe', 'inherit']; } else if (typeof d === 'string') { opts.stdio = [d, d, d]; } let expect = opts.expect === undefined ? 0 : opts.expect; delete opts.expect; // to avoid passing to spawnSync const opts2 = Object.assign({}, opts); // 0.12.x mutates const child = spawnSync(command, args, opts2); let s = child.status; // conform old node vers to https://github.com/nodejs/node/pull/11288 if (child.signal) s = null; if (child.error || s !== expect) { if (opts.stdio[1] === 'pipe' && child.stdout) { process.stdout.write(child.stdout); } else if (opts.stdio[2] === 'pipe' && child.stderr) { process.stdout.write(child.stderr); } console.log('> ' + command + ' ' + args.join(' ')); } if (child.error) { throw child.error; } if (s !== expect) { if (s === null) s = 'null'; if (expect === null) expect = 'null'; throw new Error( 'Status ' + s.toString() + ', expected ' + expect.toString() ); } if (opts.stdio[1] === 'pipe' && opts.stdio[2] === 'pipe') { return { stdout: child.stdout.toString(), stderr: child.stderr.toString(), }; } else if (opts.stdio[1] === 'pipe') { return child.stdout.toString(); } else if (opts.stdio[2] === 'pipe') { return child.stderr.toString(); } else { return ''; } }; module.exports.pkg = function () { throw new Error('Async pkg not implemented'); }; const es5path = path.resolve(__dirname, '../lib-es5/bin.js'); const es7path = path.resolve(__dirname, '../lib/bin.js'); module.exports.pkg.sync = function (args, opts) { args = args.slice(); const es5 = existsSync(es5path); const binPath = es5 ? es5path : es7path; args.unshift(binPath); assert(es5, 'RUN BABEL FIRST!'); // args.unshift('-r', 'babel-register'); if (Array.isArray(opts)) opts = { stdio: opts }; try { const ss = module.exports.spawn.sync; return ss('node', args, opts); } catch (error) { console.log(`> ${error.message}`); process.exit(2); } }; module.exports.stringify = function (obj, replacer, space) { return stableStringify(obj, { replacer, space }); }; module.exports.filesBefore = function (n) { for (const ni of n) { module.exports.vacuum.sync(ni); } return globby.sync('**/*', { nodir: true }).sort(); }; module.exports.filesAfter = function (b, n) { const a = globby.sync('**/*', { nodir: true }).sort(); for (const bi of b) { if (a.indexOf(bi) < 0) { assert(false, `${bi} disappeared!?`); } } const d = []; for (const ai of a) { if (b.indexOf(ai) < 0) { d.push(ai); } } assert(d.length === n.length, JSON.stringify([d, n])); for (const ni of n) { assert(d.indexOf(ni) >= 0, JSON.stringify([d, n])); } for (const ni of n) { module.exports.vacuum.sync(ni); } }; module.exports.shouldSkipPnpm = function () { // pnpm 8 requires at least Node.js v16.14 const REQUIRED_MAJOR_VERSION = 16; const REQUIRED_MINOR_VERSION = 14; const MAJOR_VERSION = parseInt(process.version.match(/v([0-9]+)/)[1], 10); const MINOR_VERSION = parseInt( process.version.match(/v[0-9]+\.([0-9]+)/)[1], 10 ); const isDisallowedMajor = MAJOR_VERSION < REQUIRED_MAJOR_VERSION; const isDisallowedMinor = MAJOR_VERSION === REQUIRED_MAJOR_VERSION && MINOR_VERSION < REQUIRED_MINOR_VERSION; if (isDisallowedMajor || isDisallowedMinor) { const need = `${REQUIRED_MAJOR_VERSION}.${REQUIRED_MINOR_VERSION}`; const got = `${MAJOR_VERSION}.${MINOR_VERSION}`; console.log(`skiping test as it requires nodejs >= ${need} and got ${got}`); return true; } return false; }; ================================================ FILE: tsconfig.json ================================================ { "compilerOptions": { "target": "es2017", "module": "commonjs", "allowJs": true, "declaration": true, "declarationMap": true, "sourceMap": true, "outDir": "lib-es5", "strict": true, "esModuleInterop": true, "incremental": true, "downlevelIteration": true, "resolveJsonModule": true }, "include": ["lib/**/*", "typings/**/*"] }