<commit_before>"use strict";

var app = require('../assemble/config');
var gulp = require('gulp');
var runSequence = require('run-sequence').use(gulp);
var extname = require('gulp-extname');
var controller = require('../assemble/plugins/controller.js');
var errorHandler = require('../assemble/plugins/error').handlebars;
var livereload = require('gulp-livereload');
var taskGenerator = require('../taskGenerator');
var upath = require('upath');

module.exports = function(name, config, server) {

    app.option("assets", config.assets);

    gulp.task('handlebars_update', function() {

        var renameKey = function(filename) {
            filename = filename.replace(process.cwd() + '/node_modules/', '');
            filename = filename.replace(process.cwd() + '/', '');
            filename = filename.replace('src/tmpl/partials/', '');
            filename = filename.replace(upath.extname(filename), '');
            return filename;
        };

        config.layouts.options.renameKey = renameKey;
        config.partials.options.renameKey = renameKey;

        app.layouts(config.layouts.files.src, config.layouts.options);
        app.partials(config.partials.files.src, config.partials.options);
<commit_msg>fix relative path and current package path for handlebars partials<commit_after>"use strict";

var app = require('../assemble/config');
var gulp = require('gulp');
var runSequence = require('run-sequence').use(gulp);
var extname = require('gulp-extname');
var controller = require('../assemble/plugins/controller.js');
var errorHandler = require('../assemble/plugins/error').handlebars;
var livereload = require('gulp-livereload');
var taskGenerator = require('../taskGenerator');
var upath = require('upath');

module.exports = function(name, config, server) {

    var localPackagePartials = [];

    app.option("assets", config.assets);

    gulp.task('handlebars_update', function() {

        // Double registration from partials for current package path.
        var renameKey = function(filename) {
            filename = filename.replace(process.cwd() + '/node_modules/', '');
            filename = filename.replace(process.cwd() + '/', '');
            filename = filename.replace('src/tmpl/partials/', '');
            filename = filename.replace(upath.extname(filename), '');
            if (localPackagePartials.indexOf(filename) > -1) {
                filename = upath.join(process.env.npm_package_name, filename);
            } else {
                localPackagePartials.push(filename);
            }
            console.log(filename);
            return filename;
        };

        config.partials.options.renameKey = renameKey;
        app.partials([config.partials.files.src[0]], config.partials.options);
        localPackagePartials = [];

        renameKey = function(filename) {
            filename = filename.replace(process.cwd() + '/node_modules/', '');
            filename = filename.replace(process.cwd() + '/', '');
            filename = filename.replace('src/tmpl/partials/', '');
            filename = filename.replace(upath.extname(filename), '');
            console.log(filename);
            return filename;
        };

        config.layouts.options.renameKey = renameKey;
        config.partials.options.renameKey = renameKey;

        app.partials(config.partials.files.src, config.partials.options);
        app.layouts(config.layouts.files.src, config.layouts.options);

{'fraction_non_alphanumeric': 0.15194654270772806, 'fraction_numerical': 0.0005810575246949448, 'mean_word_length': 3.050588235294118, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1842311', 'n_tokens_mistral': 971, 'n_tokens_neox': 948, 'n_words': 165}