Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Allow symlinked output directories #1322

Merged
merged 1 commit into from
Jan 2, 2016
Merged

Allow symlinked output directories #1322

merged 1 commit into from
Jan 2, 2016

Conversation

nibblebot
Copy link
Contributor

Should fix the concern the user has in #1212 where using a symlinked output directory incorrectly errors out saying An output directory must be specified when compiling a directory
/cc @ysimonson

@@ -588,6 +588,23 @@ describe('cli', function() {
});
});

it('should not error if output directory is a symlink', function(done) {
if (process.platform === 'win32') {
return done(); // no symlink support on win32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@am11 is this true? I thought Windows had a symlink equivalent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xzyfer, Windows has two kinds of symlinks: soft, junction. Both are supported by node.js. The crude difference between Windows and Unix symlinks is instead of a flat file with a simple link, Windows has it as some encrypted hash in registry (a special folder like control panel etc.). Therefore they are not portable (can't zip them, cant git-package them and so on). git add will result in adding the entire directory. If it is a junction (even the linked dir is within the repo it will read everything with new dir prefix), otherwise the softlink can't be added at all.

@xzyfer
Copy link
Contributor

xzyfer commented Dec 30, 2015

Thanks @nibblebot! Are you able to squash your commits?

I'm not sure bailing out early for Windows is correct. I've asked @am11 (our resident Windows expert) to confirm.

@nibblebot
Copy link
Contributor Author

docs on node's symlink creation API:
https://nodejs.org/api/fs.html#fs_fs_symlink_target_path_type_callback

certainly windows 'junctions', 'shortcuts' are not equivalent to symlinks; that is they are not interchangeable.

The use case I have is an existing project with symlinks (assumes UNIX). I'm not sure how common junctions are used in windows projects but if capability was needed another few lines in isDirectory might be needed and another test case specifically for junctions.

@nibblebot
Copy link
Contributor Author

and squashed

assert.deepEqual(files, ['.gitkeep', 'one.css', 'two.css', 'nested'].sort());
var nestedFiles = fs.readdirSync(path.join(dest, 'nested'));
assert.deepEqual(nestedFiles, ['three.css']);
rimraf.sync(dest+'/*');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removes everything except .gitkeep

@am11
Copy link
Contributor

am11 commented Dec 30, 2015

@nibblebot, thanks. Your fix in bin/node-sass looks good. AFAICT, there was a reason we used lstat, but I am not recalling it.

For the test, we do not store symlink within our git repos, because they are non-portable file system artifacts. Instead in the test case, create a symlink on the fly, work with it and then dispose it. You can delete all the fixtures you added in this PR. This would be a portable solution.

@nibblebot
Copy link
Contributor Author

@am11 sounds good. will take a stab at that

@nibblebot nibblebot force-pushed the master branch 2 times, most recently from 73913ac to 7c6bc8e Compare December 31, 2015 18:43
@nibblebot
Copy link
Contributor Author

squashed, setup/teardown for directory and symlink, all tests pass

@am11
Copy link
Contributor

am11 commented Dec 31, 2015

Thanks @nibblebot. We can reuse an existing fixture sub-directory instead of input-directory2 and just create a symlink in test and dispose it on close.

@nibblebot
Copy link
Contributor Author

fixed

@am11
Copy link
Contributor

am11 commented Dec 31, 2015

LGTM. 🎉

@xzyfer. PTAL.

@saper
Copy link
Member

saper commented Jan 2, 2016

Interesting: symbolic links might also to cause the issue also in #1323, where we call fs.realpathSync() and fs.lstatSync() gives ENOENT back.

@xzyfer
Copy link
Contributor

xzyfer commented Jan 2, 2016

Great work everyone!

xzyfer added a commit that referenced this pull request Jan 2, 2016
Allow symlinked output directories
@xzyfer xzyfer merged commit ec18ef5 into sass:master Jan 2, 2016
@xzyfer xzyfer added this to the next.patch milestone Jan 2, 2016
@xzyfer xzyfer removed this from the next.patch milestone Sep 4, 2016
@xzyfer xzyfer removed this from the next.patch milestone Sep 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants