2013-10-12 01:09:17 +04:00
|
|
|
path = require 'path'
|
2013-10-31 22:48:22 +04:00
|
|
|
fs = require 'fs-plus'
|
2013-10-12 01:09:17 +04:00
|
|
|
|
|
|
|
## Platform specific helpers
|
|
|
|
module.exports =
|
|
|
|
# Public: Returns true if being run from within Windows
|
|
|
|
isWindows: ->
|
|
|
|
!!process.platform.match /^win/
|
|
|
|
|
|
|
|
# Public: Some files can not exist on Windows filesystems, so we have to
|
|
|
|
# selectively generate our fixtures.
|
|
|
|
#
|
|
|
|
# Returns nothing.
|
|
|
|
generateEvilFiles: ->
|
|
|
|
evilFilesPath = path.join(__dirname, 'fixtures', 'evil-files')
|
2013-11-01 00:43:44 +04:00
|
|
|
fs.removeSync(evilFilesPath) if fs.existsSync(evilFilesPath)
|
2013-10-31 22:48:22 +04:00
|
|
|
fs.mkdirSync(evilFilesPath)
|
2013-10-12 01:09:17 +04:00
|
|
|
|
2014-01-01 03:04:04 +04:00
|
|
|
if @isWindows()
|
2013-10-12 01:09:17 +04:00
|
|
|
filenames = [
|
2014-01-01 03:04:04 +04:00
|
|
|
"a_file_with_utf8.txt"
|
|
|
|
"file with spaces.txt"
|
2013-10-12 01:09:17 +04:00
|
|
|
"utfa\u0306.md"
|
|
|
|
]
|
|
|
|
else
|
|
|
|
filenames = [
|
2014-01-01 03:04:04 +04:00
|
|
|
"a_file_with_utf8.txt"
|
|
|
|
"file with spaces.txt"
|
|
|
|
"goddam\nnewlines"
|
|
|
|
"quote\".txt"
|
2013-10-12 01:09:17 +04:00
|
|
|
"utfa\u0306.md"
|
|
|
|
]
|
|
|
|
|
|
|
|
for filename in filenames
|
2014-01-01 03:04:04 +04:00
|
|
|
fs.writeFileSync(path.join(evilFilesPath, filename), 'evil file!', flag: 'w')
|