Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symlink check #3

Closed
d13r opened this issue Sep 24, 2014 · 1 comment
Closed

Symlink check #3

d13r opened this issue Sep 24, 2014 · 1 comment

Comments

@d13r
Copy link
Contributor

d13r commented Sep 24, 2014

A check for symlinks could be useful. As a starting point, this is what I'm currently using (CoffeeScript):

fs = require('fs')

module.exports = (chai, utils) ->

  # expect(path).to.be.a.symlink()
  # expect(path).not.to.be.a.symlink()
  chai.Assertion.addMethod 'symlink', ->

    try
      isSymlink = fs.lstatSync(this._obj).isSymbolicLink()
    catch err
      # If it doesn't exist, it's clearly not a symlink
      if err.code == 'ENOENT'
        isSymlink = false
      else
        throw err

    this.assert(
      isSymlink,
      'expected #{this} to be a symlink',
      'expected #{this} not to be a symlink'
    )
@Bartvds
Copy link
Contributor

Bartvds commented Sep 24, 2014

Sure, I don't really use those so much myself but I'd definitely accept a PR for it.

Bartvds added a commit that referenced this issue Oct 22, 2014
Add .to.be.a.symlink() support. Closes #3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants