Browse Source

Use findAmberPath just as in other repos.

Herby Vojčík 3 years ago
parent
commit
4518707eae
1 changed files with 17 additions and 4 deletions
  1. 17 4
      Gruntfile.js

+ 17 - 4
Gruntfile.js

@@ -1,5 +1,21 @@
 'use strict';
 
+var fs = require('fs'),
+    path = require('path'),
+    helpers = require('@ambers/sdk').helpers;
+
+function findAmberPath(options) {
+    var result;
+    options.some(function (x) {
+        var candidate = path.join(__dirname, x);
+        return (
+            fs.existsSync(path.join(candidate, 'support/boot.js')) ||
+            fs.existsSync(path.join(candidate, 'base/boot.js'))
+        ) && (result = candidate);
+    });
+    return result;
+}
+
 module.exports = function (grunt) {
     // These plugins provide necessary tasks.
     grunt.loadNpmTasks('grunt-contrib-clean');
@@ -7,9 +23,6 @@ module.exports = function (grunt) {
     grunt.loadNpmTasks('grunt-exec');
     grunt.loadNpmTasks('@ambers/sdk');
 
-    var path = require('path'),
-        helpers = require('@ambers/sdk').helpers;
-
     // Default task.
     grunt.registerTask('default', ['amdconfig:app', 'amberc:all']);
     grunt.registerTask('test', ['amdconfig:app', 'requirejs:test_runner', 'exec:test_runner', 'clean:test_runner']);
@@ -37,7 +50,7 @@ module.exports = function (grunt) {
         // task configuration
         amberc: {
             options: {
-                amber_dir: path.join(__dirname, "node_modules", "@ambers", "lang"),
+                amber_dir: findAmberPath(['../amber/lang', 'node_modules/@ambers/lang']),
                 configFile: "config.js"
             },
             all: {