first commit
This commit is contained in:
29
build/node_modules/lnfs/cli.js
generated
vendored
Executable file
29
build/node_modules/lnfs/cli.js
generated
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
var path = require('path');
|
||||
var meow = require('meow');
|
||||
var lnfs = require('./');
|
||||
|
||||
var cli = meow({
|
||||
help: [
|
||||
'Usage',
|
||||
' $ lnfs <file> <target>',
|
||||
'',
|
||||
'Example',
|
||||
' $ lnfs foo.txt bar.txt'
|
||||
]
|
||||
});
|
||||
|
||||
if (cli.input.length < 2) {
|
||||
console.error('Source file and target required');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
lnfs(cli.input[0], cli.input[1], function (err) {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(path.resolve(cli.input[1]) + ' -> ' + path.resolve(cli.input[0]));
|
||||
});
|
||||
101
build/node_modules/lnfs/index.js
generated
vendored
Normal file
101
build/node_modules/lnfs/index.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
'use strict';
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var mkdirp = require('mkdirp');
|
||||
var rimraf = require('rimraf');
|
||||
|
||||
function link(src, dest, type, cb) {
|
||||
rimraf(dest, function (err) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
mkdirp(path.dirname(dest), function (err) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
fs.symlink(src, dest, type, cb);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function (src, dest, type, cb) {
|
||||
if (typeof src !== 'string' || typeof dest !== 'string') {
|
||||
throw new Error('Source file and target required');
|
||||
}
|
||||
|
||||
if (typeof type === 'function' && !cb) {
|
||||
cb = type;
|
||||
type = null;
|
||||
}
|
||||
|
||||
src = path.resolve(src);
|
||||
dest = path.resolve(dest);
|
||||
|
||||
fs.lstat(dest, function (err, stats) {
|
||||
if (err && err.code === 'ENOENT') {
|
||||
return link(src, dest, type, cb);
|
||||
}
|
||||
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!stats.isSymbolicLink()) {
|
||||
return link(src, dest, type, cb);
|
||||
}
|
||||
|
||||
fs.realpath(dest, function (err, res) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (res === src) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
link(src, dest, type, cb);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.sync = function (src, dest, type) {
|
||||
if (typeof src !== 'string' || typeof dest !== 'string') {
|
||||
throw new Error('Source file and target required');
|
||||
}
|
||||
|
||||
src = path.resolve(src);
|
||||
dest = path.resolve(dest);
|
||||
|
||||
try {
|
||||
var stats = fs.lstatSync(dest);
|
||||
var realpath = fs.realpathSync(dest);
|
||||
|
||||
if (!stats.isSymbolicLink()) {
|
||||
rimraf.sync(dest);
|
||||
fs.symlinkSync(src, dest, type);
|
||||
return;
|
||||
}
|
||||
|
||||
if (realpath === src) {
|
||||
return;
|
||||
}
|
||||
|
||||
rimraf.sync(dest);
|
||||
fs.symlinkSync(src, dest, type);
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
mkdirp.sync(path.dirname(dest));
|
||||
fs.symlinkSync(src, dest, type);
|
||||
return;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
21
build/node_modules/lnfs/license
generated
vendored
Normal file
21
build/node_modules/lnfs/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
66
build/node_modules/lnfs/package.json
generated
vendored
Normal file
66
build/node_modules/lnfs/package.json
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"_from": "lnfs@^1.0.0",
|
||||
"_id": "lnfs@1.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-n0354PF4z2Jv6Vdf8So69AG8iLw=",
|
||||
"_location": "/lnfs",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "lnfs@^1.0.0",
|
||||
"name": "lnfs",
|
||||
"escapedName": "lnfs",
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/pngout-bin/bin-wrapper"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/lnfs/-/lnfs-1.1.0.tgz",
|
||||
"_shasum": "9f4df9e0f178cf626fe9575ff12a3af401bc88bc",
|
||||
"_spec": "lnfs@^1.0.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/pngout-bin/node_modules/bin-wrapper",
|
||||
"author": {
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "https://github.com/kevva"
|
||||
},
|
||||
"bin": {
|
||||
"lnfs": "cli.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/kevva/lnfs/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"meow": "^3.3.0",
|
||||
"mkdirp": "^0.5.0",
|
||||
"rimraf": "^2.2.8"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Safely force create symlinks",
|
||||
"devDependencies": {
|
||||
"ava": "^0.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"cli.js",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/kevva/lnfs#readme",
|
||||
"keywords": [],
|
||||
"license": "MIT",
|
||||
"name": "lnfs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/kevva/lnfs.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test.js"
|
||||
},
|
||||
"version": "1.1.0"
|
||||
}
|
||||
77
build/node_modules/lnfs/readme.md
generated
vendored
Normal file
77
build/node_modules/lnfs/readme.md
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
# lnfs [](https://travis-ci.org/kevva/lnfs)
|
||||
|
||||
> Safely force create symlinks
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save lnfs
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var symlink = require('lnfs');
|
||||
|
||||
symlink('foo.txt', 'bar.txt', function (err) {
|
||||
console.log('Symlink successfully created!');
|
||||
});
|
||||
|
||||
symlink.sync('foo.txt', 'bar.txt');
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### lnfs(src, dest, type, callback)
|
||||
|
||||
#### src
|
||||
|
||||
*Required*
|
||||
Type: `string`
|
||||
|
||||
Path to source file.
|
||||
|
||||
#### dest
|
||||
|
||||
*Required*
|
||||
Type: `string`
|
||||
|
||||
Path to destination.
|
||||
|
||||
#### type
|
||||
|
||||
Type: `string`
|
||||
Default: `file`
|
||||
|
||||
Can be set to `dir`, `file`, or `junction` and is only available on Windows (ignored on other platforms).
|
||||
|
||||
#### callback(err)
|
||||
|
||||
Type: `function`
|
||||
|
||||
Returns nothing but a possible exception.
|
||||
|
||||
|
||||
## CLI
|
||||
|
||||
```
|
||||
$ npm install --global lnfs
|
||||
```
|
||||
|
||||
```
|
||||
$ lnfs --help
|
||||
|
||||
Usage
|
||||
$ lnfs <file> <target>
|
||||
|
||||
Example
|
||||
$ lnfs foo.txt bar.txt
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Kevin Mårtensson](https://github.com/kevva)
|
||||
Reference in New Issue
Block a user