matype / stylefmt

stylefmt is a tool that automatically formats stylesheets.
Other
2.1k stars 88 forks source link

Error: ENOENT: no such file or directory #236

Open zoxon opened 8 years ago

zoxon commented 8 years ago

After the update I get the error

Error: ENOENT: no such file or directory, stat 'E:\OpenServer\domains\html\gulp-front\source\static\styles\main.css'
    at Error (native)
Error: ENOENT: no such file or directory, stat 'E:\OpenServer\domains\html\gulp-front\source\static\styles\reset.css'
    at Error (native)

I'm use gulp-postcss wiht stylefmt, error is disappear if disable this plugin.

Gulp task

var plumber = require('gulp-plumber');
var sourcemaps = require('gulp-sourcemaps');
var stylus = require('gulp-stylus');
var combineMq = require('gulp-combine-mq');
var postcss = require('gulp-postcss');
var csso = require('gulp-csso');
var rename = require('gulp-rename');
var browserSync = require('browser-sync').create();
var rupture = require('rupture');
var autoprefixer = require('autoprefixer');
var stylefmt = require('stylefmt');
var postcssSorting = require('postcss-sorting');
var postcssSortingConfig = JSON.parse(
        fs.readFileSync(
            path.join(__dirname, './.postcss-sorting.json')
        )
    );

var options = {
    browserSync: {
        server: {
            baseDir: './dest'
        }
    },

    stylus: {
        use: [
            rupture(),
            stylusFileExists()
        ],
        'include css': true
    },

    postcss: [
        autoprefixer({
            cascade: false
        }),
        stylefmt(),
        postcssSorting(postcssSortingConfig)
    ],

    csso: {
        restructure: true,
        sourceMap: true
    }

};

gulp.task('build:css', function() {
    return gulp.src([ '*.styl', '!_*.styl' ], { cwd: 'source/static/styles' })
        .pipe(plumber(options.plumber))
        .pipe(sourcemaps.init())
        .pipe(stylus(options.stylus))
        .pipe(combineMq({ beautify: true }))
        .pipe(postcss(options.postcss))
        .pipe(gulp.dest('dest/assets/stylesheets'))
        .pipe(csso(options.csso))
        .pipe(rename({ suffix: '.min' }))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('dest/assets/stylesheets'))
        .pipe(browserSync.stream());
});

Full gulpfile.js My .stylelintrc and .postcss-sorting.json

My app

Test on Windows 8.1 x64, Windows 7 x64, Windows 10 x64 NPM 3.5.3 Node.js 4.2.4 and 6.9.1

PS. Change task for readability

TrySound commented 7 years ago

@zoxon Show full stacktrace please

gucong3000 commented 7 years ago

@TrySound gulp-stylus will rename '.styl' to '.css', then ‘stylelint’ will pass opts.from to cosmiconfig, then cosmiconfig will throw this error.

TrySound commented 7 years ago

@gucong3000 Why cosmiconfig loads css?

gucong3000 commented 7 years ago

At the time of the release, There's code like this

stat = fs.statSync(filepath);
return stat.isDirectory();

https://github.com/davidtheclark/cosmiconfig#loadsearchpath-configpath This function accepts file paths or folder paths

Other tools that depend on postcss in the future may run into this problem when running under gulp-postcss

zoxon commented 7 years ago

@TrySound Sory it was a long time ago I think it was my mistake. When I'm set configFile option stylefmt stop throwing this error.

-       stylefmt(),
+       stylefmt({
+           configFile: '.stylelintrc'
+       }),

https://github.com/zoxon/gulp-front/commit/b99e82a3c36085bff7ce62cc13262a90543b5e7f#diff-b9e12334e9eafd8341a6107dd98510c9R206

This is the error in console, only this two errors

Error: ENOENT: no such file or directory, stat 'E:\OpenServer\domains\html\gulp-front\source\static\styles\main.css'
    at Error (native)
Error: ENOENT: no such file or directory, stat 'E:\OpenServer\domains\html\gulp-front\source\static\styles\reset.css'
    at Error (native)