forked from sindresorhus/gulp-ruby-sass
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
37 lines (33 loc) · 1016 Bytes
/
Copy pathutils.js
File metadata and controls
37 lines (33 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
var path = require('path');
var glob = require('glob');
var glob2base = require('glob2base');
var gutil = require('gulp-util');
var md5Hex = require('md5-hex');
exports.emitErr = function (stream, err) {
stream.emit('error', new gutil.PluginError('gulp-ruby-sass', err));
};
// Create unique temporary directory path per task using cwd, options, sources,
// and all matched files. Sourcemap option switching does not break Sass cache
// so we do it ourselves. Possibly a bug: https://github.com/sass/sass/issues/1830
exports.createIntermediatePath = function (sources, matches, options) {
return path.join(
options.tempDir,
'gulp-ruby-sass',
md5Hex(
process.cwd() +
JSON.stringify(sources) +
JSON.stringify(matches) +
options.sourcemap
)
);
};
exports.calculateBase = function (source) {
return glob2base(new glob.Glob(source));
};
exports.replaceLocation = function (origPath, currentLoc, newLoc) {
return path.join(
newLoc,
path.relative(currentLoc, origPath)
);
};