diff --git a/index.js b/index.js index 6b0f5bc..ba35068 100644 --- a/index.js +++ b/index.js @@ -42,21 +42,20 @@ const filePush = (file, compileResult, callback) => { // Grab the path portion of the file that's being worked on const sassFileSrcPath = path.dirname(sassFileSrc); - const rxp = new RegExp(`${sassFileSrc}\$`); + const rxp = new RegExp(`${sassFileSrc}$`); const base = file.path.replace(rxp, ''); if (sassFileSrcPath) { let sourceFileIndex = sassMap.sources.indexOf(sassMapFile); if (sourceFileIndex === -1) { - sourceFileIndex = sassMap.sources.indexOf('file://' + sassMapFile); + sourceFileIndex = sassMap.sources.indexOf(`file://${sassMapFile}`); } // Prepend the path to all files in the sources array except the file that's being worked on sassMap.sources = sassMap.sources.map((source, index) => { // Make path relative if (source.startsWith('file://')) { - let relative = path.relative(base, source.replace(/^file:/, '')); - return relative; + return path.relative(base, source.replace(/^file:/, '')); } return index === sourceFileIndex diff --git a/test/main.js b/test/main.js index b60d674..e468b67 100644 --- a/test/main.js +++ b/test/main.js @@ -249,13 +249,6 @@ describe('gulp-sass -- async compile', () => { + '"sourcesContent": [ "@import ../inheritance;" ]' + '}'; - // Expected sources are relative to file.base - const legacyExpectedSources = [ - 'inheritance.scss', - 'includes/_cats.scss', - 'includes/_dogs.sass', - ]; - // Going forward the source map typically uses absolute file: URLs, // although this can be controlled by custom importers const expectedSources = [ @@ -449,13 +442,6 @@ describe('gulp-sass -- sync compile', () => { it('should work with gulp-sourcemaps', (done) => { const sassFile = createVinyl('inheritance.scss'); - // Expected sources are relative to file.base - const legacyExpectedSources = [ - 'inheritance.scss', - 'includes/_cats.scss', - 'includes/_dogs.sass', - ]; - // Going forward the source map typically uses absolute file: URLs, // although this can be controlled by custom importers const expectedSources = [ @@ -486,18 +472,6 @@ describe('gulp-sass -- sync compile', () => { }); it('should work with gulp-sourcemaps and autoprefixer', (done) => { - const legacyExpectedSourcesBefore = [ - 'inheritance.scss', - 'includes/_cats.scss', - 'includes/_dogs.sass', - ]; - - const legacyExpectedSourcesAfter = [ - 'includes/_cats.scss', - 'includes/_dogs.sass', - 'inheritance.scss', - ]; - const expectedSourcesBefore = [ 'data:', 'includes/_cats.scss', @@ -510,11 +484,8 @@ describe('gulp-sass -- sync compile', () => { 'data:', ]; - if (MODERN_COMPILER) { - const result = 'inheritance.css'; - legacyExpectedSourcesAfter.push(result); - expectedSourcesAfter.push(result); - } + const result = 'inheritance.css'; + expectedSourcesAfter.push(result); gulp.src(path.join(__dirname, 'scss', 'inheritance.scss')) .pipe(sourcemaps.init()) @@ -564,18 +535,6 @@ describe('gulp-sass -- sync compile', () => { }); it('should work with gulp-sourcemaps and autoprefixer with different file.base', (done) => { - const legacyExpectedSourcesBefore = [ - 'scss/inheritance.scss', - 'scss/includes/_cats.scss', - 'scss/includes/_dogs.sass', - ]; - - const legacyExpectedSourcesAfter = [ - 'scss/includes/_cats.scss', - 'scss/includes/_dogs.sass', - 'scss/inheritance.scss', - ]; - const expectedSourcesBefore = [ 'scss/data:', 'scss/includes/_cats.scss', @@ -590,7 +549,6 @@ describe('gulp-sass -- sync compile', () => { if (MODERN_COMPILER) { const result = 'scss/inheritance.css'; - legacyExpectedSourcesAfter.push(result); expectedSourcesAfter.push(result); }