Giter Site home page Giter Site logo

gulp-wrap's People

Contributors

adamayres avatar doug avatar duncanbeevers avatar giladgray avatar martfors avatar nate-wilkins avatar santosh-shaastry avatar shinnn avatar thedancingcode avatar toilal avatar zaim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gulp-wrap's Issues

Remove file.path.match(/json$/) and support inner objects

Check json format with JSON.parse (or other method), rather than a file extension, because I can generate json-object as js- or coffee-file then to wrap it in js or coffee.

If I use inner object I get [object Object]. You need to Stringify data in plugin

F.e.

gulp.src('configs/')
  .pipe(generateConfigFiles('<%= projectName %>/config.js'))
  .pipe(wrap('define(["app"], function(app) {app.constant("config", <%= contents.public %>);});')))
  .pipe(gulp.dest('compiled/configs/'))

0.12.0 not working with gulp-handlebars, 0.11.0 works fine

I raised an issue over at the gulp-handlebars repo. They give the following example in their documentation which makes use of gulp-wrap:

gulp.task('templates', function(){
  gulp.src('source/templates/*.hbs')
    .pipe(handlebars({
      handlebars: require('handlebars')
    }))
    .pipe(wrap('Handlebars.template(<%= contents %>)'))
    .pipe(declare({
      namespace: 'MyApp.templates',
      noRedeclare: true, // Avoid duplicate declarations
    }))
    .pipe(concat('templates.js'))
    .pipe(gulp.dest('build/js/'));
});

I've been using gulp-handlebars 4.0.0, handlebars 4.0.5, and gulp-wrap 0.11.0 together for a while now. Everything plays nice. Just started a new project with the above and gulp-wrap 0.12.0 and I got the following error:

{ [TypeError: tmpl is not a function]
  name: 'TypeError',
  message: 'tmpl is not a function',
  stack: 'TypeError: tmpl is not a function\n
    at /Users/aaron.cordova/Projects/Sandbox/walmart-search/node_modules/consolidate/lib/consolidate.js:779:16\n
    at /Users/aaron.cordova/Projects/Sandbox/walmart-search/node_modules/consolidate/lib/consolidate.js:143:5\n
    at Promise._execute (/Users/aaron.cordova/Projects/Sandbox/walmart-search/node_modules/bluebird/js/release/debuggability.js:272:9)\n
    at Promise._resolveFromExecutor (/Users/aaron.cordova/Projects/Sandbox/walmart-search/node_modules/bluebird/js/release/promise.js:473:18)\n
    at new Promise (/Users/aaron.cordova/Projects/Sandbox/walmart-search/node_modules/bluebird/js/release/promise.js:77:14)\n
    at promisify (/Users/aaron.cordova/Projects/Sandbox/walmart-search/node_modules/consolidate/lib/consolidate.js:136:10)\n
    at Function.exports.lodash.render (/Users/aaron.cordova/Projects/Sandbox/walmart-search/node_modules/consolidate/lib/consolidate.js:775:10)\n
    at /Users/aaron.cordova/Projects/Sandbox/walmart-search/node_modules/gulp-wrap/index.js:73:37\n
    at process._tickCallback (node.js:401:9)',
  showStack: false,
  showProperties: true,
  plugin: 'gulp-wrap' }

Just wanted to make your team aware. Thanks.

Cannot get the file name only

Maybe i have missed something here but how can i get the file name only. I do not want the full path, just the file name (including or excluding the extension, i dont mind)

Unhandled promise rejection?

I get:

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError in plugin 'gulp-wrap'

message: 'processPartialName is not defined'

When doing this:

.pipe( wrap('Handlebars.registerPartial(<%= processPartialName(file.relative) %>, Handlebars.template(<%= contents %>));', {}, {
	imports: {
		processPartialName: function ( fileName ) {
			// Strip the extension and the underscore
			// Escape the output with JSON.stringify
			return JSON.stringify( path.basename( fileName, '.js' ).substr(1) );
		}
	}
}));

Anyone else get this? And how to fix it?

Possible to pass front-matter value to template src?

The following is incorrect but illustrates what I'm trying to do: pull the value set for template in each of the source file's front matter and pass it src of the wrap. Is this doable?

gulp.task('build', function() {
  gulp.src('./content/**/*.md')
    .pipe(frontMatter({
      property: 'data'
    }))
    .pipe(wrap({
      src: <% data.template %>
    }))
    .pipe(gulp.dest(paths.build))
});

contents is [object Object]?

I use wrap in my code like this:

var _config = gulp.src('pkg/seajs/organization.json')
        .pipe(wrap('seajs.config(<%= contents  %>);'))
        .pipe(gulp.dest('js', {cwd : config.dist}))
  }

but the output is

seajs.config([object Object]);

the contents is not correct

Expose path parts in templates

Similar to contents, when:

file.path => path/to/foo.png

expose:

dirname   => to
basename  => foo.png
filename  => foo
extension => png

Parsing this inside templates is super awkward, yet these properties are really useful.

Provide template as a stream

It would be nice to have ability to pass template contents as a stream.
For example if my template is in jade format and I use gulp-jade to compile it. Something like:

var templateStream = gulp.src("./src/template.jade").pipe(jade());

gulp.src("./src/*.json")
    .pipe(wrap({ stream: templateStream }))
    .pipe(gulp.dest("./dist"));

What do you think?

Remove es6-promise?

promise in node seems to be well supported now from version 4+, perhaps we can remove it now?
feels unnecessary to include dependencies that you don't need when running node 6.1.0+

Users can always install it and set it as global if they are running an older version. And i don't think people don't mind to update if they see a warning if you put "node": ">=4.0.0" in the package.json

Unhandled rejection TypeError: tmpl is not a function

Hi,
gulp-wrap throws an exception when i use it.

Here ir the piece of code in my gulpfile.js:

gulp.task('build:word-merge', function() {
    return gulp.src('word-merge/*.js')
        .pipe(concat('word-merge.js'))
        .pipe(wrap('(function(){\n"use strict";\n<%= contents %>\n})();')
        .pipe(gulp.dest(buildPath))
        .pipe(uglify())
        .pipe(rename('word-merge.min.js'))
        .pipe(gulp.dest(buildPath));
});

And here the console log:

Unhandled rejection TypeError: tmpl is not a function
    at D:\Proyectos\openxml.js\node_modules\consolidate\lib\consolidate.js:779:16
    at D:\Proyectos\openxml.js\node_modules\consolidate\lib\consolidate.js:143:5

    at Promise._execute (D:\Proyectos\openxml.js\node_modules\bluebird\js\release\debuggability.js:272:9)
    at Promise._resolveFromExecutor (D:\Proyectos\openxml.js\node_modules\bluebird\js\release\promise.js:473:18)
    at new Promise (D:\Proyectos\openxml.js\node_modules\bluebird\js\release\promise.js:77:14)
    at promisify (D:\Proyectos\openxml.js\node_modules\consolidate\lib\consolidate.js:136:10)
    at Function.exports.lodash.render (D:\Proyectos\openxml.js\node_modules\consolidate\lib\consolidate.js:775:10)
    at D:\Proyectos\openxml.js\node_modules\gulp-wrap\index.js:73:37
    at process._tickCallback (node.js:412:9)

For more info, I'm using the version 5.9.1 of node.js

Thanks

PS: sorry about my horrible english

Replace deprecated dependency gulp-util

gulp-util has been deprecated recently. Continuing to use this dependency may prevent the use of your library with the latest release of Gulp 4 so it is important to replace gulp-util.

The README.md lists alternatives for all the components so a simple replacement should be enough.

Your package is one of the most popular packages still relying on gulp-util, it would be good to publish a fixed version to npm as soon as possible.

See:

Failing to create Nunjucks template

Trying to get a bunch of markdown files converted into html, wrapped with a Nunjucks template, and then saved into a folder (where they can then be processed and turned into public files).

The gulp-wrap process will create an HTML file, but only duplicating the template over. It will not populate due to gulp errors with Nunjucks - specifically, how my existing gulpfile wants 'extends' written, and how gulp-wrap wants it formatted (in this case, the full file path, rather that local filepath).

Is there a way to disable the Nunjucks render so that gulp-wrap only replaces the relevant information on the template?

amd - commonjs conversion question

Is it possible with gulp-wrap to convert amd modules to commonjs and standard js modules? That conversion is not just about wrapping, it should parse the amd file and read the required dependencies...

At the end of how to remove the added content

我遇到这种情况;
在gulp-watch中需要对js文件添加defined包裹,watch结束时,需要去掉define,
请问有没有办法使用呢?
谢谢!
I encountered such a situation;
In gulp-watch need to add define to the JS file, the end of watch, need to remove define

Is there any way to use?
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.