javascriptangularjsnode.jsgruntjsgrunt-contrib-copy

SyntaxError: expected expression, got '.' grunt-copy


First of all, I'm new with grunt and angularjs, basically it is my first real project. I like to use continuous integration, because of that I decide to use grunt to structure my distribution code.

I use the grunt-contrib-copy (https://github.com/gruntjs/grunt-contrib-copy) with the follow Gruntfile.js file configuration:

module.exports = function(grunt) {

// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);

// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);

// Define the configuration for all the tasks
grunt
    .initConfig({

    // Automatically inject Bower components into the app
    bowerInstall : {
        target : {
        src : [ 'index.html' ],
        exclude : [
            'bower_components/angular/angular.min.js',
            'bower_components/angular-route/angular-route.min.js',
            'bower_components/angular-sanitize/angular-sanitize.min.js',
            'bower_components/angular-translate/angular-translate.min.js',
            'bower_components/bootstrap/dist/js/bootstrap.min.js',
            'bower_components/bootstrap-social/js/bootstrap.min.js',
            'bower_components/jquery/dist/jquery.min.js',
            'bower_components/metisMenu/dist/metisMenu.min.js',
            'bower_components/morrisjs/morris.min.js',
            'bower_components/raphael/raphael-min.js' ]
        }
    },

    // Copies remaining files to places other tasks can use
    copy : {
        html : {
        src : 'index.html',
        dest : 'dist/index.html'
        },
        angular : {
        expand : true,
        cwd : 'app',
        dest : 'dist/app',
        src : [ '**/*.js' ]
        },
        bower : {
        expand : true,
        cwd : 'bower_components',
        dest : 'dist/bower_components',
        src : [ '**/*.*' ]
        },
        assets : {
        expand : true,
        cwd : 'assets',
        dest : 'dist/assets',
        src : '**/*.{png,jpg,jpeg,gif,css}'
        },
        views : {
        expand : true,
        cwd : 'views',
        dest : 'dist/views',
        src : '**/*.html'
        }
    },

    targethtml : {
        dist : {
        files : {
            'dist/index.html' : 'dist/index.html'
        }
        }
    },

    compress : {
        main : {
        options : {
            mode : 'tgz',
            archive : 'target/geneBlab.tgz'
        },
        files : [ {
            expand : true,
            src : '**/*',
            cwd : 'dist/',
            dot : true
        } ]
        }
    }
    });

grunt.registerTask('default', [ 'copy' ]);

};

My structure folder is:

-app
  |--app.js
  |--controllers
  |   |...      
  |--i18
  |   |...
  |--js
  |...
-bower_components
  |...
-views
  |...
-assets
  |...
-index.html

Before I run the grunt command, I have structured it correctly into dist folder, but unfortunately when I try to open the index.html firebug, it shows me the follow error into all javascript files: SyntaxError: expected expression, got '.'


One of my angular javascript files:

'use strict';

testControllers
.controller(
    'testController',
    [
        '$scope',
        '$http',
        '$routeParams',
        'dnaToolsService',

        function($scope, $http, $routeParams, dnaToolsService) {

            /***************************************************
             * VARIABLES
             **************************************************/

            /**
             * Control the input/output flow
             */
            $scope.status = 'input';

            $scope.dna = new Object();

            $scope.openDetails = new Array();

            /***************************************************
             * INPUT/OUTPUT METHODS
             **************************************************/

            /**
             * Calculate the dna sequence result
             */
            $scope.calculateResult = function($dna) {

            $scope.dna = callGetSpeciesUsingDna();

            $scope.status = 'output';

            // Start the array to hide and show details
            for (var index = 0; index < $scope.dna.speciesList.length; index++) {
                $scope.openDetails.push(false);
            }

            };

            /**
             * Show the data detail
             */
            $scope.showDetails = function($index, $simpleDetail) {
            $scope.openDetails[$index] = ($scope.openDetails[$index] == false) ? true
                : false;
            }

            /**
             * Back the page to input
             */
            $scope.back = function() {
            $scope.status = 'input';
            };

            /***************************************************
             * INTERNAL/HELP METHODS
             **************************************************/

            function callGetSpeciesUsingDna() {
            return dnaToolsService.getSpeciesUsingDna();
            }

            this.params = $routeParams;

        } ]);

Why is it happen?

Thanks for the time ;)


Solution

  • You believe the problem is because of the plugin version? :D

    I'm use the grunt-copy and this plugin was decrepated...I changed the plugin for grunt-contrib-copy and all start works correctly :O

    Link ref: https://github.com/gruntjs/grunt-contrib-copy/issues/223

    Thanks all.