diff --git a/index.js b/index.js index 2b94d1bd2f4..8cace404770 100644 --- a/index.js +++ b/index.js @@ -10,3 +10,6 @@ require('styles/main.less'); // App JavaScript files require('scripts/app.js'); + +require('morpho'); + diff --git a/package.json b/package.json index 19670c239f6..154ef900eb2 100644 --- a/package.json +++ b/package.json @@ -93,6 +93,7 @@ "webpack-dev-server": "^1.14.1", "worker-loader": "^0.7.0", "yaml-js": "^0.1.3", + "file-loader": "^0.8.5", "morpho": "~0.0.1-alpha.6" }, "engines": { diff --git a/scripts/components.js b/scripts/components.js index cc261686bb6..670cd7bdb91 100644 --- a/scripts/components.js +++ b/scripts/components.js @@ -59,6 +59,7 @@ require('scripts/directives/tryoperation.js'); // Enums require('scripts/enums/defaults.js'); require('scripts/enums/strings.js'); +require('scripts/enums/simpleYaml.js'); // Filter require('scripts/filters/formdata.js'); diff --git a/app/scripts/enums/simpleYaml.js b/scripts/enums/simpleYaml.js similarity index 100% rename from app/scripts/enums/simpleYaml.js rename to scripts/enums/simpleYaml.js diff --git a/scripts/services/builder.js b/scripts/services/builder.js index 3796e1360e3..6d3769b57e2 100644 --- a/scripts/services/builder.js +++ b/scripts/services/builder.js @@ -65,30 +65,30 @@ SwaggerEditor.service('Builder', function Builder(SwayWorker, simpleYaml, Prefer } Preferences.set('simpleYAML', enableSimpleYaml); - var prom = new Promise(function(resolve1, reject1) { - if(enableSimpleYaml){ - var errors = []; - simpleYaml.model = Morpho.convertFrom['yaml'].call(Morpho, stringValue, errors, {addDefaults:true}, function(errors){ - if(errors&&errors.length>0){ - var newError = _.map(errors,function(error){ - return {simpleYamlError:error}; - }); + var prom = new Promise(function(resolve1, reject1) { + if(enableSimpleYaml){ + var errors = []; + simpleYaml.model = Morpho.convertFrom['yaml'].call(Morpho, stringValue, errors, {addDefaults:true}, function(errors){ + if(errors&&errors.length>0){ + var newError = _.map(errors,function(error){ + return {simpleYamlError:error}; + }); - reject({ - errors: newError, - specs: null - }); - } else { - resolve1(); + reject({ + errors: newError, + specs: simpleYaml.swagger + }); + } else { + resolve1(); + } + }); + var result; + if(!!simpleYaml.model){ + simpleYaml.swagger = json = Morpho.convertTo['swagger'].call(Morpho, simpleYaml.model, errors, {returnJSON:true}); } - }); - var result; - if(!!simpleYaml.model){ - simpleYaml.swagger = json = Morpho.convertTo['swagger'].call(Morpho, simpleYaml.model, errors, {returnJSON:true}); } - } - else {resolve1();} - }); + else {resolve1();} + }); prom.then(function() { // Add `title` from object key to definitions @@ -106,17 +106,19 @@ SwaggerEditor.service('Builder', function Builder(SwayWorker, simpleYaml, Prefer } } - SwayWorker.run({ - definition: json - }, function(data) { - if (data.errors.length) { - reject(data); - } else { - resolve(data); - } + SwayWorker.run({ + definition: json + }, function(data) { + if (data.errors.length) { + reject(data); + } else { + resolve(data); + } + }); }); }); }; this.buildDocs = buildDocs; + }); diff --git a/webpack.config.js b/webpack.config.js index a88856c3572..40ec6f8c3a9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -43,7 +43,12 @@ var config = { }, { test: /\.worker.js$/, - loader: 'worker-loader' + loader: 'worker-loader', + exclude: 'node_modules/' + }, + { + test: /simpleYamlWorker.js$/, + loader: 'file?name=[name].[ext]' }, { test: /\.png$/,