Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let data = fs.readFileSync(filepath, 'utf-8')
if (path.extname(filepath) === '.fountain') {
try {
// write scene ids for any new scenes
data = ensureFountainSceneIds(filepath, data)
let [scriptData, locations, characters, metadata] = processFountainData(data, false, false)
mainWindow.webContents.send('reloadScript', [scriptData, locations, characters])
} catch (error) {
dialog.showMessageBox({
type: 'error',
message: 'Could not reload script.\n' + error.message
})
}
} else if (path.extname(filepath) === '.fdx') {
let parser = new xml2js.Parser()
parser.parseString(data, (err, fdxObj) => {
if (err) {
dialog.showMessageBox({
type: 'error',
message: 'Could not parse Final Draft XML.\n' + error.message,
})
return
}
try {
ensureFdxSceneIds(fdxObj)
let [scriptData, locations, characters, metadata] = processFdxData(fdxObj)
mainWindow.webContents.send('reloadScript', [scriptData, locations, characters])
} catch (error) {
dialog.showMessageBox({
let defaultApis = Enumerable(fs.readdirSync(path.join(resources, common.defaultLang, 'apis'))).where(name => path.extname(name) === jsonExt).orderBy(element => path.basename(element, jsonExt)).toArray();
// let defaultChanges = Enumerable(fs.readdirSync(path.join(resources, common.defaultLang, 'change'))).where(name => path.extname(name) === jsonExt).orderBy(element => path.basename(element, jsonExt), (element, other) => {
assert.equal(path.dirname('\\\\unc\\share\\foo'), '\\\\unc\\share\\');
assert.equal(path.dirname('\\\\unc\\share\\foo\\'), '\\\\unc\\share\\');
assert.equal(path.dirname('\\\\unc\\share\\foo\\bar'),
'\\\\unc\\share\\foo');
assert.equal(path.dirname('\\\\unc\\share\\foo\\bar\\'),
'\\\\unc\\share\\foo');
assert.equal(path.dirname('\\\\unc\\share\\foo\\bar\\baz'),
'\\\\unc\\share\\foo\\bar');
}
assert.equal(path.extname(''), '');
assert.equal(path.extname('/path/to/file'), '');
assert.equal(path.extname('/path/to/file.ext'), '.ext');
assert.equal(path.extname('/path.to/file.ext'), '.ext');
assert.equal(path.extname('/path.to/file'), '');
assert.equal(path.extname('/path.to/.file'), '');
assert.equal(path.extname('/path.to/.file.ext'), '.ext');
assert.equal(path.extname('/path/to/f.ext'), '.ext');
assert.equal(path.extname('/path/to/..ext'), '.ext');
assert.equal(path.extname('file'), '');
assert.equal(path.extname('file.ext'), '.ext');
assert.equal(path.extname('.file'), '');
assert.equal(path.extname('.file.ext'), '.ext');
assert.equal(path.extname('/file'), '');
assert.equal(path.extname('/file.ext'), '.ext');
assert.equal(path.extname('/.file'), '');
assert.equal(path.extname('/.file.ext'), '.ext');
assert.equal(path.extname('.path/file.ext'), '.ext');
assert.equal(path.extname('file.ext.ext'), '.ext');
assert.equal(path.extname('file.'), '.');
assert.equal(path.extname('.'), '');
function mimeFromExt( fname ) {
var ext = path.extname(fname);
if (ext) {
var mime = mimeTypes[ext.substr(1)];
if (mime) return mime;
}
return "text/plain";
}
css = util.flatten(css).filter((filepath) => {
return (path.extname(filepath) !== '.map')
});
browser.reload(css);
finder.on('file', (file, stat) => {
if (path.extname(file) === '.ts') {
this.scannedFiles.push(file);
}
});
function check(req, res, name) {
var ext = path.extname(name) || '.' + (res.app.get('view engine') || 'html');
var root = req.app.get('views') || process.cwd() + '/views';
var dir = path.dirname(name) == '.' ? root : path.resolve(root, path.dirname(name));
return partials.lookup(dir, path.basename(name, ext), ext);
}
async postProcess (generated) {
const css = generated.find(e => e.type === 'css')
if (css) {
const { exts, limit } = await getOptions()
for (let i of this.dependencies) {
const [key, val] = i
const { name, resolved } = val
const basename = path.basename(name)
const extname = path.extname(basename).replace('.', '')
if (exts.includes(extname)) {
const file = await read(resolved, 'binary')
if (file.length <= limit) {
const hashname = this.generateBundleName.call({
relativeName: basename,
type: extname
})
const regexp = new RegExp(hashname, 'g')
collection.set(hashname, { basename, path: resolved })
const base64str = await base64(file, basename)
css.value = css.value.replace(regexp, base64str)
}
}
}
}
return generated
getManifestExtension(directory: string): string {
let manifest = this.getManifestFile(directory);
return manifest ? path.extname(manifest).replace('.', '') : 'scss';
}