How to generate css in the correct directory (gulp)?

The problem is that helpful to be very far from the sass files, and css generates relative helpfile,
how to make what they would generalise in the css folder to one directory higher than the sass file?
here is my Galp file:
var path = require("path");
var gulp = require('gulp'),
sass = require('gulp-sass'),
rename = require("gulp-rename"),
flatten = require('gulp-flatten'),
plumber = require('gulp-plumber'),
gutil = require('gulp-util');

var onError = function (err) {
gutil.beep();
console.log(err);
};

gulp.task('sass', function () {
gulp.src('**/sass/*.scss')
.pipe(plumber({errorHandler: onError}))
.pipe(sass())
.pipe(flatten({includeParents: 0}))
.pipe(gulp.dest(function (file) {
var dir = path.dirname(file.path).split('/scss')
return dir[1] ? path.join(dir[0], 'css', dir[1]) : path.join(dir[0], 'css');
}))
});

gulp.task('watch', function () {
gulp.watch('**/sass/*.scss', ['sass']);

});

//
Tried with such Calphalon
var path = require("path");
var gulp = require('gulp'),
sass = require('gulp-sass'),
debug = require('gulp-debug'),
plumber = require('gulp-plumber');

var onError = function (err) {
gutil.beep();
console.log(err);
};

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

gulp.src('**/sass/*.scss' , {cwd: __dirname} )
.pipe(plumber({errorHandler: onError}))
.pipe(sass())
.pipe(debug({title: 'unicorn:'}))
.pipe(gulp.dest('../css', {cwd: __dirname}))
});

gulp.task('watch', function () {
gulp.watch('**/sass/*.scss', ['sass']);

});
July 8th 19 at 15:34
2 answers
July 8th 19 at 15:36
Solution
Test no time, but I don't think there's a problem.

var path = require('path'),
 gulp = require('gulp'),
 sass = require('gulp-sass'),
 rename = require('gulp-rename');

gulp.task('sass', function () {
 return gulp.src('**/sass/*.scss')
.pipe(sass())
 .pipe(rename(function (filePath) {
 filePath.dirname = path.join(filePath.dirname, '../css/');
 return filePath;
}))
.pipe(gulp.dest('./'));
});
works like a clock))Thank you very much! - benedict_McKenzie commented on July 8th 19 at 15:39
that's where progeny found - Durward_Osinski commented on July 8th 19 at 15:42
July 8th 19 at 15:38
Maybe it makes no special plugin?

Find more questions by tags Gulp.jsNode.js