Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('file exits', t => {
const fp = tempy.file();
fs.writeFileSync(fp, '');
t.throws(() => {
makeDir.sync(fp);
}, {code: 'EEXIST'});
});
it(`should reject with a ValidationError when 'networkTimeoutSeconds' is used and handler is not 'NetworkFirst'`, async function() {
const swDest = tempy.file({extension: 'js'});
const runtimeCachingOptions = {
networkTimeoutSeconds: 1,
};
const runtimeCaching = [{
urlPattern: REGEXP_URL_PATTERN,
handler: 'NetworkOnly',
options: runtimeCachingOptions,
}];
const options = Object.assign({}, BASE_OPTIONS, {
runtimeCaching,
swDest,
});
try {
await generateSW(options);
throw new Error('Unexpected success.');
test('save option', async t => {
const outputPath = tempy.file()
await mocha({
files: [getFixturePath('pass.js')],
save: outputPath,
reporter: 'tap'
})
const output = await fs.readFile(outputPath, 'utf8')
t.true(output.includes('# pass 1'), 'expect 1 pass')
})
import { directory, file, root } from "tempy";
//
const tempDir2: string = directory();
const tempFile: string = file();
const pngFile: string = file({ extension: "png" });
const fileWithName: string = file({ name: "afile.txt" });
const tmpRoot: string = root;
import { directory, file, root } from "tempy";
//
const tempDir2: string = directory();
const tempFile: string = file();
const pngFile: string = file({ extension: "png" });
const fileWithName: string = file({ name: "afile.txt" });
const tmpRoot: string = root;
map(files, file => {
const temp = tempy.file({ extension: 'png' });
return decode(file, temp).then(() => temp);
})
.map(file => {
async function getTransactions (options = {}) {
const daysAgo = new Date()
daysAgo.setDate(daysAgo.getDate() - options.numberOfDays)
const {
startDate = daysAgo,
endDate = new Date(),
username,
password,
shallShowBrowser = false,
} = options
const nightmare = new Nightmare({show: shallShowBrowser})
const baseUrl = 'https://my.hypovereinsbank.de'
const filePathTemp = tempy.file({name: 'hypovereinsbank-transactions.csv'})
const log = process.env.NODE_DEBUG
? console.warn
: () => {}
const url = `${baseUrl}/login?view=/de/login.jsp`
log(`Open ${url}`)
await nightmare
.goto(url)
.wait('#loginPanel')
log('Log in')
await nightmare
.insert('#loginPanel #username', username)
.insert('#loginPanel #px2', password)
.click('#loginCommandButton')
async function getTransactions (options = {}) {
const daysAgo = new Date()
daysAgo.setDate(daysAgo.getDate() - options.numberOfDays)
const {
startDate = daysAgo,
endDate = new Date(),
username,
password,
shallShowBrowser = false,
} = options
const nightmare = new Nightmare({show: shallShowBrowser})
const baseUrl = 'https://www.dkb.de'
const filePathTemp = tempy.file({name: 'dkb-transactions.csv'})
const log = process.env.NODE_DEBUG
? console.warn
: () => {}
const loginUrl = `${baseUrl}/banking`
log(`Open ${loginUrl}`)
await nightmare
.goto(loginUrl)
.wait('#login')
log('Log in')
await nightmare
.insert('#loginInputSelector', username)
.insert('#pinInputSelector', password)
.click('#buttonlogin')
.then(() => {
const filepath = tempy.file({extension: 'html'});
file.path = filepath;
file.path = path.join(folder, path.basename(filepath));
file.base = folder;
file.contents = Buffer.from(opts.html);
debug(file);
gc.addFile(filepath);
return fs.outputFile(filepath, file.contents).then(() => {
return file;
});
});
}
function backup(filename) {
const file = filename || tmp.file({ extension : '.sql' });
debug(`#backup() beginning backup routine.`);
return mysqldump(file)
.then(() => xz(file))
.then(upload);
}