pulsar/spec/spec-helper-platform.js
Sadick 83d6c09b10
Decaffeinate specs (#21546)
Decaffeinate the following files.

* atom-protocol-handler
* babel-spec
* buffered-node-process
* buffered-process
* clipboard
* context-menu-manager
* decoration-manager
* default-directory-provider
* deserializer-manager
* file-system-blob-store
* keymap-extensions
* menu-manager
* module-cache
* pane-axis-element
* pane-container-element
* pane-element
* package-spec
* squirel-update
* styles-element-spec
* task-spec
* typescript-spec
* spec-helper-platform
2020-10-30 16:40:57 +03:00

46 lines
1.1 KiB
JavaScript

const path = require('path');
const fs = require('fs-plus');
// # Platform specific helpers
module.exports = {
// Public: Returns true if being run from within Windows
isWindows() {
return !!process.platform.match(/^win/);
},
// Public: Some files can not exist on Windows filesystems, so we have to
// selectively generate our fixtures.
//
// Returns nothing.
generateEvilFiles() {
let filenames;
const evilFilesPath = path.join(__dirname, 'fixtures', 'evil-files');
if (fs.existsSync(evilFilesPath)) {
fs.removeSync(evilFilesPath);
}
fs.mkdirSync(evilFilesPath);
if (this.isWindows()) {
filenames = [
'a_file_with_utf8.txt',
'file with spaces.txt',
'utfa\u0306.md'
];
} else {
filenames = [
'a_file_with_utf8.txt',
'file with spaces.txt',
'goddam\nnewlines',
'quote".txt',
'utfa\u0306.md'
];
}
filenames.map(filename =>
fs.writeFileSync(path.join(evilFilesPath, filename), 'evil file!', {
flag: 'w'
})
);
}
};