Sunday, 7 May 2017

Is there a way to stop elm.init() in gulp-elm from moving elm-stuff and elm-package.json into the parent directory?

I'm trying to use gulp-elm with a monolithic architecture. I have setup my project dir with client and server directories and I've put my gulp file in the main directory. The directory structure is pretty simple.

project/
    gulpfile.js
    package.json
    client/
        elm-package.json
    server/
        ...

When i run, for example, gulp elm-init with the following task:

// File paths
var paths = {
  dest: 'client/dist',
  elm: 'client/src/*.elm',
  static: 'client/src/*.{html,css}'
};

// Init Elm
gulp.task('elm-init', function(){
  return elm.init({ cwd : 'client' });
});

// Compile Elm to HTML
/*gulp.task('elm', ['elm-init'], function(){
    return gulp.src(paths.elm)
        .pipe(plumber())
        .pipe(elm({ cwd : 'client' }))
        .pipe(gulp.dest(paths.dest));
});*/

the elm-stuff folder and elm-package.json get moved to the main project directory. Is this expected? if not, is there a correct way to use a gulpfile from the parent directory to build an elm package in a nested directory? I think my effort matches the example.

gulp.task('init-nested', function(){
  return elm.init({cwd: 'elm/nested-elm/'});
});

gulp.task('nested', ['init-nested'], function(){
  return gulp.src('elm/nested-elm/*.elm')
    .pipe(elm.make({filetype: 'html', cwd: 'elm/nested-elm/'}))
    .pipe(gulp.dest('dest/'));
});

I've tried looking at the source, as well as following dependencies to see if i could figure it out myself, but i'm relatively unfamiliar with node so it's hard for me to figure out exactly what's going on in the gulp-elm source(link 4) (as well as one of the deps (link 3) i checked out.)

3: https:// github.com/IndigoUnited/node-cross-spawn

4: https:// github.com/philopon/gulp-elm/commit/c6027e15378d783c36f492a558ecfcd4442dc28b

(quotes and broken links are to get around needing 10 rep to post 3+ links yuck, just remove the space between https:// and github.com)



via omgoshjosh

No comments:

Post a Comment