mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 16:28:50 +00:00
30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
|
|
var fs = require("fs");
|
||
|
|
var path = require("path");
|
||
|
|
var depsDir = path.join(__dirname, "..", "deps");
|
||
|
|
var map = require("../map.json");
|
||
|
|
|
||
|
|
// Each file in the `deps` directory expresses the dependencies of a stub.
|
||
|
|
// For example, `deps/http.js` calls `require("http-browserify")` to
|
||
|
|
// indicate that the `http` stub depends on the `http-browserify` package.
|
||
|
|
// This makes it easy for a bundling tool like Browserify, Webpack, or
|
||
|
|
// Meteor to include the appropriate package dependencies by depending on
|
||
|
|
// `meteor-node-stubs/deps/http` rather than having to know how the `http`
|
||
|
|
// stub is implemented. Some modules in the `deps` directory are empty,
|
||
|
|
// such as `deps/fs.js`, which indicates that no dependencies need to be
|
||
|
|
// bundled. Note that these modules should not be `require`d at runtime,
|
||
|
|
// but merely scanned at bundling time.
|
||
|
|
|
||
|
|
fs.mkdir(depsDir, function () {
|
||
|
|
require("rimraf")("deps/*.js", function (error) {
|
||
|
|
if (error) throw error;
|
||
|
|
Object.keys(map).forEach(function (id) {
|
||
|
|
fs.writeFileSync(
|
||
|
|
path.join(depsDir, id + ".js"),
|
||
|
|
typeof map[id] === "string"
|
||
|
|
? "require(" + JSON.stringify(map[id]) + ");\n"
|
||
|
|
: ""
|
||
|
|
);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|