nicosantangelo / sublime-gulp

Run Gulp tasks and use snippets from Sublime Text
https://sublime-gulp.nicosantangelo.com/
MIT License
155 stars 18 forks source link

STDERR does not get displayed properly on non utf encodings #33

Closed nicosantangelo closed 9 years ago

nicosantangelo commented 9 years ago

When using encodings like cp866 (Cyrillic) if cmd fails writing the cache or running the gulp task the output wont be properly encoded:

This is a problem with Windows using a different encoding for STDERR and STDOUT.

Sigmanor commented 9 years ago

It's weird! I still can catching this bug, sometimes. And sometimes it's working fine. Now I'm trying to understand why it sometimes works and sometimes not

UPD

Well :open_mouth: When I open sublime text with admin permissions, package working almost fine, I get this error: (Translate: Class not registered)
But i think its chrome issue. In the rest all working fine.

nicosantangelo commented 9 years ago

The fact that you get this problem from time to time leads me to believe is a problem with the Windows ENV variable (it happened to me from time to time running Windows this last couple of days). You can take a look here, it could be helpful.

As for the Class not registered, keep me posted, right now I think it might not be related to Sublime Gulp

Lastly, I still have to test it, but I think I finally fixed the encoding issues on b9dcaac

Sigmanor commented 9 years ago

@NicoSantangelo I found out that Class not registered was a chrome issue, this error is not related to sublime text or to your package. And i got some new error, i will write about it later.

nicosantangelo commented 9 years ago

This is up! Last version is v4.5.0, if you're using Package Control you can use the List packages command to check which version of sublime-gulp you have.

This should fix the nonsensical characters so you can see the output. If you're still having this error from time to time we can open a new issue :)

If you want, let me know how it goes

Sigmanor commented 9 years ago

@NicoSantangelo It still working just when I open sublime text with admin permissions. And in one my project i get this error:

sublime-gulp.log:

07-09-2015 17:19: D:\Program Files\Sublime Text\Data\Packages\Gulp\write_tasks_to_cache.js:55 gulp.tree({ deep: true }).forEach(function(task) { ^ TypeError: undefined is not a function at _forEachTask4x (D:\Program Files\Sublime Text\Data\Packages\Gulp\write_tasks_to_cache.js:55:10) at forEachTask (D:\Program Files\Sublime Text\Data\Packages\Gulp\write_tasks_to_cache.js:42:9) at Object. (D:\Program Files\Sublime Text\Data\Packages\Gulp\write_tasks_to_cache.js:79:5) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) at startup (node.js:129:16) at node.js:814:3

But from cmd my project builds successfully.

nicosantangelo commented 9 years ago

Could you tell me which gulp version are you running in the project that does not work? ( gulp -v )

Sigmanor commented 9 years ago

3.9.0 version, and in other project where your package works, too 3.9.0 version

nicosantangelo commented 9 years ago

@Sigmanor Sorry for the massive delay, I'm not having a lot of free time lately.

if you're seeing this error in a 3.9.0 gulp project:

07-19-2015 00:49:
/Users/xx/Library/Application Support/Sublime Text 3/Packages/Gulp/write_tasks_to_cache.js:55
    gulp.tree({ deep: true }).forEach(function(task) {
         ^
TypeError: undefined is not a function
    at _forEachTask4x (/Users/xx/Library/Application Support/Sublime Text 3/Packages/Gulp/write_tasks_to_cache.js:55:10)
    at forEachTask (/Users/xx/Library/Application Support/Sublime Text 3/Packages/Gulp/write_tasks_to_cache.js:42:9)
    at Object.<anonymous> (/Users/xx/Library/Application Support/Sublime Text 3/Packages/Gulp/write_tasks_to_cache.js:79:5)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

It probably means that somewhere in your gulpfile.js you're setting gulp.tasks to a falsy value. Sublime-gulp uses the tasks property found on the gulp object to generate the cache.

For example, to recreate this error on my local gulp project, I've added gulp.tasks = undefined; to the end of my gulpfile.js

If you're not doing this, could you paste your gulpfile here?

Sigmanor commented 9 years ago

@NicoSantangelo

gulpfile.js


'use strict';
var gulp = require('gulp'),
    watch = require('gulp-watch'),
    prefixer = require('gulp-autoprefixer'),
    uglify = require('gulp-uglify'),
    rigger = require('gulp-rigger'),
    cssmin = require('gulp-minify-css'),
    imagemin = require('gulp-imagemin'),
    pngquant = require('imagemin-pngquant'),
    rimraf = require('rimraf'),
    browserSync = require("browser-sync"),
    livereload = require('gulp-livereload'),
    removeCode = require('gulp-remove-code'),
    ftp = require('vinyl-ftp'),
    csscomb = require('gulp-csscomb'),
    reload = browserSync.reload;
var path = {
    build: {
        html: 'build/sigmanor.tk/',
        agl: 'build/sigmanor.tk/aion-game-launcher/',
        js: 'build/sigmanor.tk/js/',
        css: 'build/sigmanor.tk/style/',
        img: 'build/sigmanor.tk/img/',
        fonts: 'build/sigmanor.tk/fonts/'
    },
    src: {
        html: 'src/*.html',
        agl: ['src/aion-game-launcher/*.html'],
        js: 'src/js/*.js',
        style: 'src/style/*.css',
        img: 'src/img/**/*.*',
        fonts: 'src/fonts/**/*.*'
    },
    watch: {
        html: 'src/**/*.html',
        js: 'src/js/**/*.js',
        style: 'src/style/**/*.css',
        img: 'src/img/**/*.*',
        fonts: 'src/fonts/**/*.*'
    },
    clean: './build'
};
var config = {
    server: {
        baseDir: "./build/sigmanor.tk/"
    },
    tunnel: true,
    host: 'localhost',
    port: 9000,
    notify: false
};
gulp.task('webserver', function () {
    browserSync(config);
});
gulp.task('clean', function (cb) {
    rimraf(path.clean, cb);
});
gulp.task('html:build', function () {
    gulp.src(path.src.html)
        .pipe(rigger())
        .pipe(gulp.dest(path.build.html));
});
gulp.task('agl:build', function () {
    gulp.src(path.src.agl)
        .pipe(rigger())
        .pipe(gulp.dest(path.build.agl));
});
gulp.task('js:build', function () {
    gulp.src(path.src.js)
        .pipe(rigger())
        .pipe(uglify())
        .pipe(gulp.dest(path.build.js));
});
gulp.task('style:build', function () {
    gulp.src(path.src.style)
        .pipe(prefixer())
        .pipe(cssmin())
        .pipe(gulp.dest(path.build.css));
});
gulp.task('image:build', function () {
    gulp.src(path.src.img)
        .pipe(imagemin({
            progressive: true,
            svgoPlugins: [{
                removeViewBox: false
            }],
            use: [pngquant()],
            interlaced: true
        }))
        .pipe(gulp.dest(path.build.img));
});
gulp.task('fonts:build', function() {
    gulp.src(path.src.fonts)
        .pipe(gulp.dest(path.build.fonts))
});
gulp.task('lr', function () {
    livereload.listen();
    gulp.watch(['build/**/*.html', 'build/**/*.css']).on('change', livereload.changed);
});
gulp.task('build', [
    'html:build',
    'agl:build',
    'js:build',
    'style:build',
    'image:build',
    'fonts:build'
]);
gulp.task('watch', function () {
    watch([path.watch.html], function (event, cb) {
        gulp.start('html:build');
    });
    watch([path.watch.html], function (event, cb) {
        gulp.start('agl:build');
    });
    watch([path.watch.style], function (event, cb) {
        gulp.start('style:build');
    });
    watch([path.watch.js], function (event, cb) {
        gulp.start('js:build');
    });
    watch([path.watch.img], function (event, cb) {
        gulp.start('image:build');
    });
});
gulp.task('default', ['build', 'lr', 'watch']);
gulp.task('assets', function () { 

    var webm = gulp.src('src/aion-game-launcher/agl-slider.webm')
    .pipe(gulp.dest('build/sigmanor.tk/aion-game-launcher/'));
    var fav1 = gulp.src('src/favicon.png')
    .pipe(gulp.dest('build/sigmanor.tk/'));

    var fav2 = gulp.src('src/aion-game-launcher/favicon.png')
    .pipe(gulp.dest('build/sigmanor.tk/aion-game-launcher/'));
    var download = gulp.src('src/aion-game-launcher/download/*.*')
    .pipe(gulp.dest('build/sigmanor.tk/aion-game-launcher/download/'));
  return (webm, fav1, fav2, download);
});
gulp.task('pro', function () {
    gulp.src('build/**/*.html')
        .pipe(removeCode({
            production: true
        }))
        .pipe(gulp.dest('build'));
});
gulp.task('cc', function () {
    gulp.src('src/style/main.css')
        .pipe(csscomb())
        .pipe(prefixer())
        .pipe(gulp.dest('src/style/'));
});
gulp.task('ftp', function () {
    var conn = ftp.create({
        host: 'sigmanor.tk',
        user: 'login',
        password: 'password',
        parallel: 10
    });

    var globs = [
        'build/**',
        '!build/sigmanor.tk/aion-game-launcher/download/c1.txt',
        '!build/sigmanor.tk/ftpsync.settings'
    ];
    return gulp.src(globs, {
            base: './build/sigmanor.tk',
            buffer: false
        })
        //   .pipe( conn.newer( '/fh3809b8.bget.ru/public_html/test' ) ); // only upload newer files
        .pipe(conn.dest('/public_html'));
});
//.pipe(reload({stream: true}));

I got this error:


07-20-2015 10:16:
D:\Program Files\Sublime Text\Data\Packages\Gulp\write_tasks_to_cache.js:55
    gulp.tree({ deep: true }).forEach(function(task) {
         ^
TypeError: undefined is not a function
    at _forEachTask4x (D:\Program Files\Sublime Text\Data\Packages\Gulp\write_tasks_to_cache.js:55:10)
    at forEachTask (D:\Program Files\Sublime Text\Data\Packages\Gulp\write_tasks_to_cache.js:42:9)
    at Object. (D:\Program Files\Sublime Text\Data\Packages\Gulp\write_tasks_to_cache.js:79:5)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

And when i deleted comments from my gulpfile i got this error:


"gulp" is not recognized as an internal or external command, operable program or batch file.

nicosantangelo commented 9 years ago

As you said, the problem lies in the last comment, right now the package appends ;module.exports = gulp; to the last line instead of adding a newline before.

I'll correct this in the next package version (thanks a lot for letting me know!), if you don't want to remove the comment at the end you can just add a newline like:

//.pipe(reload({stream: true}));

Now, if you're getting "gulp" is not recognized as an internal or external command, operable program or batch file. when running a specific task, it usually means that:

  1. You need to install gulp both locally and globally in your project
  2. There's a problem with the environment, which can be forced by using exec_args

Does any of those two help you?

Sigmanor commented 9 years ago

@NicoSantangelo
About "gulp" is not recognized as an internal or external command, operable program or batch file. when I run the "gulp" command from the console all is working. And when i run the Sublime Text with admin permissions your package works too.

UPD

Now all ok, there really was a problem with the environment. Ty for help!

nicosantangelo commented 9 years ago

Awesome! if you find any more issues please let me know!