Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

dest parameter is not being used. #25

Closed
zachwolf opened this Issue Oct 9, 2013 · 7 comments

Comments

Projects
None yet
5 participants

zachwolf commented Oct 9, 2013

I'm having issues with the dest option not starting from the root of the project. For example, my Gruntfile.js looks something like this:

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    markdown: {
      all: {
        files: [
          {
            expand: true,
            src: 'src/markdown/*.md',
            dest: 'src/html/',
            ext: '.html'
          }
        ]
      }
    },
    watch: {
    }
  });

  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-markdown');

  grunt.registerTask('default', ['markdown']);
};

When running grunt markdown, the files are generated into ./src/html/src/markdown/(filename).html. Is this the intended behavior? I tried a few different things in the dest option, such as "./src/html/" and "../../src/html", but it didn't change the output location.

vohedge commented Oct 16, 2013

I have the same issue. I think the dest option should be started from the root of the project.

I also am getting the same issue.

Grunt Task 
markdown: {
              all: {
                    files: [
                        {
                            expand: true,
                            src:  'public/*.md',
                            dest: 'public/docs',
                            ext:  '.html'
                        }
                    ]
                }
}

Output

> Running "markdown:all" (markdown) task
> File "public/docs/public/sample.html" created.

> Done, without errors.

Ideally this would generate the files in... public/docs

This seems to give the desired effect... http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

markdown: {
    all: {
        files: [
            {
                expand: true,
                flatten: true,
                src:  'public/**/*.md',
                dest: 'public/docs',
                ext:  '.html'
            }
        ]
    }
}

Adding the flatten: true, makes this work.

vohedge commented Oct 17, 2013

flatten: true option makes all html into the same directory.
In my case, desc has some sub directories. So, directory structure has broken.

flatten: true was the solution for what my problem was. I think it's an unintuitive setting, but if that's the standard for grunt then I understand keeping it this way.

@vohedge, can you clarify the issue you're having?

vohedge commented Nov 5, 2013

Thank you @zachwolf .

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        markdown: {
            all: {
                files: [
                    {
                        expand: true,
                        src: 'markdown/**/*.md',
                        dest: 'manuals/',
                        ext: '.html'
                    }
                ]
            }
        },
        watch: {
            markdown: {
                files: 'markdown/**/*.md',
                 tasks: ['markdown']
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-markdown');

    grunt.registerTask('default', ['watch']);
};

Output

Running "markdown:all" (markdown) task
File "manuals/markdown/guidelines/manual.html" created.
File "manuals/markdown/index.html" created.
File "manuals/markdown/setup/hosts.html" created.
File "manuals/markdown/setup/publickey.html" created.

I think markdown directory should not be contained.

With flatten: true option.

Running "markdown:all" (markdown) task
File "manuals/manual.html" created.
File "manuals/index.html" created.
File "manuals/hosts.html" created.
File "manuals/publickey.html" created.

This is my issue.
Sub directories(guidelines, setup) has gone.

I expect :

File "manuals/guidelines/manual.html" created.
File "manuals/index.html" created.
File "manuals/setup/hosts.html" created.
File "manuals/setup/publickey.html" created.

I was using this:

{
    "all": {
      "files": [
        {
          "expand": true,
          "src": [
            "**/*.md",
            "!<%= project.build.styles %>/**/*.md",
            "!<%= project.node_modules %>/**/*.md",
            "!<%= project.build.styleguide %>/**/*.md",
            "!<%= project.static.docs %>/**/*.md",
            "!<%= project.dev.vendor %>/**/*.md"
          ],
          "dest": ["**/*"],
          "ext": ".html"
        }
      ],
      "options": {
        "template": "<%= project.dev.docs %>/markdown-template.jst"
      }
    }
  }

Which was working, in terms of outputting compiled .html in the same folder as the processed .md file, but now causes this error:

Warning: Arguments to path.join must be strings

According to this post on SO:

dest property must be a string. but not an Array.

However if I remove the wrapping Array, the compiled .md files are output to a folder named ** in the root of the project.

@treasonx treasonx closed this May 17, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment