Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/node_modules/js-yaml/examples/custom_types.js')
-rw-r--r--tools/eslint/node_modules/js-yaml/examples/custom_types.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/tools/eslint/node_modules/js-yaml/examples/custom_types.js b/tools/eslint/node_modules/js-yaml/examples/custom_types.js
index 02d8754fad1..b5c7b9f7de0 100644
--- a/tools/eslint/node_modules/js-yaml/examples/custom_types.js
+++ b/tools/eslint/node_modules/js-yaml/examples/custom_types.js
@@ -79,23 +79,23 @@ var SpaceYamlType = new yaml.Type('!space', {
var SPACE_SCHEMA = yaml.Schema.create([ SpaceYamlType, PointYamlType ]);
-
-// And read a document using that schema.
-
-fs.readFile(path.join(__dirname, 'custom_types.yml'), 'utf8', function (error, data) {
- var loaded;
-
- if (!error) {
- loaded = yaml.load(data, { schema: SPACE_SCHEMA });
- console.log(util.inspect(loaded, false, 20, true));
- } else {
- console.error(error.stack || error.message || String(error));
- }
-});
-
+// do not execute the following if file is required (http://stackoverflow.com/a/6398335)
+if (require.main === module) {
+
+ // And read a document using that schema.
+ fs.readFile(path.join(__dirname, 'custom_types.yml'), 'utf8', function (error, data) {
+ var loaded;
+
+ if (!error) {
+ loaded = yaml.load(data, { schema: SPACE_SCHEMA });
+ console.log(util.inspect(loaded, false, 20, true));
+ } else {
+ console.error(error.stack || error.message || String(error));
+ }
+ });
+}
// There are some exports to play with this example interactively.
-
module.exports.Point = Point;
module.exports.Space = Space;
module.exports.PointYamlType = PointYamlType;