1 | pathModule = require("path")
|
2 | os = require "os"
|
3 | fs = require "fs"
|
4 | exports.copySync = (from,to)->
|
5 | symlinkSupports = ["linux","darwin"]
|
6 | if os.platform() in symlinkSupports
|
7 | if not fs.existsSync pathModule.resolve from
|
8 | throw new Error "file #{pathModule.resolve from} not exists"
|
9 | fs.symlinkSync (pathModule.resolve from),to
|
10 | else
|
11 | throw new Error "leafjs-tester not support on your platform"
|
12 | exports.getFileInSearchPath = (file,pathes)->
|
13 | for path in pathes
|
14 | if fs.existsSync pathModule.resolve path,file
|
15 | return fs.readFileSync (pathModule.resolve path,file),"utf8"
|
16 | throw new Error "file #{file} not found in search pathes:\n #{pathes.join('\n')}" |
\ | No newline at end of file |