Skip to content

Commit

Permalink
Further lint updates
Browse files Browse the repository at this point in the history
  • Loading branch information
neild3r committed Nov 22, 2023
1 parent 27214ac commit df101ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 48 deletions.
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 2 additions & 44 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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',
Expand All @@ -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())
Expand Down Expand Up @@ -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',
Expand All @@ -590,7 +549,6 @@ describe('gulp-sass -- sync compile', () => {

if (MODERN_COMPILER) {
const result = 'scss/inheritance.css';
legacyExpectedSourcesAfter.push(result);
expectedSourcesAfter.push(result);
}

Expand Down

0 comments on commit df101ab

Please sign in to comment.