Пример #1
0
var unzipPackage = function(archive, session, options) {
	var zip = new AdmZip(archive);

	zip.extractAllTo(tmpFolder, false, options.overwrite);

	let extractedFolders = fs.readdirSync(tmpFolder);
	let extractedPath = path.join(tmpFolder, extractedFolders[0]);
	let cssPath = path.join(extractedPath, 'css');
	let fontPath = path.join(extractedPath, 'font');
	let cssFiles = fs.readdirSync(cssPath);
	let fontFiles = fs.readdirSync(fontPath);
	let cwd = process.cwd();

	if (!fs.existsSync(path.join(cwd, options.css))) { fs.mkdirSync(path.join(cwd, options.css)); }
	if (!fs.existsSync(path.join(cwd, options.fonts))) { fs.mkdirSync(path.join(cwd, options.fonts)); }

	for (var i in cssFiles) {
		fs.copyFileSync(path.join(cssPath, cssFiles[i]), path.join(cwd, options.css, cssFiles[i]));
	}

	for (var i in fontFiles) {
		fs.copyFileSync(path.join(fontPath, fontFiles[i]), path.join(cwd, options.fonts, fontFiles[i]));
	}

	var config = require(path.join(extractedPath, 'config.json'));

	// Added session to config.
	config.session = session;

	fs.writeFileSync(path.join(cwd, options.config), JSON.stringify(config, null, '\t'));
}
Пример #2
0
function setupNpmConfig() {
	exec.execSync(`rm -f package-lock.json`);
	const content = `
email=\${NPM_EMAIL}
//registry.npmjs.org/:_authToken=\${NPM_TOKEN}
`;
	fs.writeFileSync(`.npmrc`, content);

	// Workaround. see https://github.com/lerna/lerna/issues/361
	fs.copyFileSync('.npmrc', 'detox/.npmrc');
	fs.copyFileSync('.npmrc', 'detox-cli/.npmrc');
}
Пример #3
0
 it('ENOTDIR if parent of newPath is file', done => {
   fs.copyFileSync('tmptest/tmp', 'tmptest/c')
   mvfile('tmptest/a/b', 'tmptest/c/d', [,'replace'], (err, xstat) => {
     expect(err.code).to.equal('ENOTDIR')
     done()
   })
 })
Пример #4
0
 beforeEach(async () => {
   await rimrafAsync(tmptest)
   await mkdirpAsync(tmptest)
   fs.copyFileSync('testdata/alonzo_church.jpg', 'tmptest/tmp')
   fs.mkdirSync('tmptest/a')
   await mkfileAsync('tmptest/a/b', 'tmptest/tmp', null, [])
 })
Пример #5
0
function cp(src, dest) {
	if (fs.copyFileSync) {
		fs.copyFileSync(src, dest)
	} else {
		fs.writeFileSync(dest, fs.readFileSync(src))
	}
}
Пример #6
0
 it('should accept $cherryPick and give the good values', function (done) {
   const archiveBase = `${mockDir}/DirNew/ExtArchive.7z`
   const archive = `${tmpDir}/list-exist.7z`
   copyFileSync(archiveBase, archive)
   const seven = list(archive, { recursive: true, $cherryPick: '*.txt' })
   const data = []
   const expectedData = [
     { attributes: '....A', size: 9, sizeCompressed: undefined, file: 'DirExt/root.txt' },
     { attributes: '....A', size: 9, sizeCompressed: undefined, file: 'DirExt/sub1/sub1.txt' },
     { attributes: '....A', size: 9, sizeCompressed: undefined, file: 'DirExt/sub2/sub2.txt' }
   ]
   seven.on('data', d => data.push(d))
   seven.on('end', function () {
     const withoutDatetime = data
       .map(function (d) {
         const { datetime, ...rest } = d
         return rest
       })
     const dates = data.map(d => d.datetime)
     for (let d of dates) {
       expect(d).to.be.a('date')
     }
     expect(withoutDatetime).to.deep.contain(expectedData[0])
     expect(withoutDatetime).to.deep.contain(expectedData[1])
     expect(withoutDatetime).to.deep.contain(expectedData[2])
     expect(data.length).to.equal(3)
     done()
   })
 })
Пример #7
0
(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  const result = [];

  for (const de of sentences) {
    const url = `https://www.deepl.com/translator#de/en/${de}`;
    await page.goto(url);
    await page.waitFor(1200);
    const translated = await page.evaluate(
      () => document.querySelectorAll('.lmt__textarea')[1].value,
    );
    if (translated) {
      result.push(`${translated}\t${de}\t\t${DEFAULT_TAGS}`);
    } else {
      errors.push(de);
    }
  }

  await browser.close();

  fs.writeFileSync(OUTPUT_FILE_PATH, result.join('\n'), 'utf8');
  console.log(`Got ${result.length} sentences`);
  if (errors.length) {
    fs.copyFileSync(INPUT_FILE_PATH, INPUT_FILE_PATH + '.bak');
    fs.writeFileSync(INPUT_FILE_PATH, errors.join('\n'), 'utf8');
    console.log(`Couldn't translate ${errors.length} entries`);
  }
})();
	it( 'Should insert inline image', async () => {
		// Create a paragraph.
		await page.click( '.editor-default-block-appender' );
		await page.keyboard.type( 'a ' );

		await insertBlock( 'Inline Image' );

		// Wait for media modal to appear and upload image.
		await page.waitForSelector( '.media-modal input[type=file]' );
		const inputElement = await page.$( '.media-modal input[type=file]' );
		const testImagePath = path.join( __dirname, '..', 'assets', '10x10_e2e_test_image_z9T8jK.png' );
		const filename = uuid();
		const tmpFileName = path.join( os.tmpdir(), filename + '.png' );
		fs.copyFileSync( testImagePath, tmpFileName );
		await inputElement.uploadFile( tmpFileName );

		// Wait for upload.
		await page.waitForSelector( '.media-modal li[aria-label="' + filename + '"]' );

		// Insert the uploaded image.
		await page.click( '.media-modal button.media-button-select' );

		// Check the content.
		const regex = new RegExp( '<!-- wp:paragraph -->\\s*<p>a\\u00A0<img class="wp-image-\\d+" style="width:\\s*10px;?" src="[^"]+\\/' + filename + '\\.png" alt=""\\/><\\/p>\\s*<!-- \\/wp:paragraph -->' );
		expect( await getEditedPostContent() ).toMatch( regex );
	} );
Пример #9
0
 fs.readdirSync(from).forEach(element => {
     if (fs.lstatSync(Path.join(from, element)).isDirectory()) {
         copyFolder(Path.join(from, element), Path.join(dest, element));
     } else {
         fs.copyFileSync(Path.join(from, element), Path.join(dest, element));
     }
 });
Пример #10
0
   click: () => {
     const myLogFilePath = `${app.getPath('documents')}/yoriki-v5/log.txt`;
     console.log(`dist dir:${myLogFilePath}`)
     console.log(`log file path:${findLogPath()}`);
     fs.copyFileSync(findLogPath(), myLogFilePath);
     shell.openItem(myLogFilePath);
 }
Пример #11
0
        it('Can click Go button to visit password URL (Without http protocol).', async function () {

            //sets test timeout to 10s
            this.timeout(10000);

            fs.copyFileSync('test/local_test_page.html', 'public_html/local_test_page.html');

            //refresh the driver
            await driver.get(testVars.TEST_UNENCRYPTED_URL);

            //create URL based password
            var data = support.getTestData(testVars.TEST_GOOGLE_URL_NO_PROTOCOL);
            await support.addPassword(driver, true, data);

            await driver.findElement(webdriver.By.id('p0-toggle')).click();
            await driver.findElement(webdriver.By.id('p0-go')).click();

            await sleep(4000);

            var handles = await driver.getAllWindowHandles();
            var secondWindowHandle = handles[1];
            var firstWindowHandle = handles[0];

            await driver.switchTo().window(secondWindowHandle);

            assert.equal(await driver.getCurrentUrl(), "https://" + testVars.TEST_GOOGLE_URL_NO_PROTOCOL + "/?gws_rd=ssl");

            //close secondary window only
            await driver.close();

            await driver.switchTo().window(firstWindowHandle);
            
            fs.unlinkSync('public_html/local_test_page.html');
        });
Пример #12
0
exports.installSource = async function installSource({
  license = 'basic',
  password = '******',
  sourcePath,
  basePath = BASE_PATH,
  installPath = path.resolve(basePath, 'source'),
  log = defaultLog,
}) {
  log.info('source path: %s', chalk.bold(sourcePath));
  log.info('install path: %s', chalk.bold(installPath));
  log.info('license: %s', chalk.bold(license));

  const metadata = await sourceInfo(sourcePath, license, log);
  const dest = path.resolve(basePath, 'cache', metadata.filename);

  const cacheMeta = cache.readMeta(dest);
  const isCached = cacheMeta.exists && cacheMeta.etag === metadata.etag;
  const archive = isCached ? dest : await createSnapshot({ sourcePath, log, license });

  if (isCached) {
    log.info('source path unchanged since %s, using cache', chalk.bold(cacheMeta.ts));
  } else {
    cache.writeMeta(dest, metadata);
    fs.copyFileSync(archive, dest);
  }

  return await installArchive(dest, {
    license,
    password,
    basePath,
    installPath,
    log,
  });
};
Пример #13
0
 it('EEXIST + EISFILE, if newPath is file', done => {
   mkdirp.sync('tmptest/c')
   fs.copyFileSync('testdata/foo', 'tmptest/c/d')
   mvfile('tmptest/a/b', 'tmptest/c/d', [], (err, xstat) => {
     expect(err.code).to.equal('EEXIST')
     expect(err.xcode).to.equal('EISFILE')
     done()
   })
 })
Пример #14
0
	copyDrawableFile(tool, tmp, path) {
		var appPath = tool.manifestPath.split("/");
		appPath[appPath.length - 1] = "android";
		appPath = appPath.join("/");
		var source = appPath + path;
		if (!FS.existsSync(source))
			source = tool.homePath + "/build/android/inNDK/Play/project/res" + path;
		var destination = tmp + "/ndk/project/res" + path;
		FS.copyFileSync(source, destination);
	}
Пример #15
0
gulp.task('vsix:release:package', (onError) => __awaiter(this, void 0, void 0, function* () {
    del.sync(projectPaths_1.vscodeignorePath);
    fs.copyFileSync(projectPaths_1.onlineVscodeignorePath, projectPaths_1.vscodeignorePath);
    try {
        yield spawnNode_1.default([projectPaths_1.vscePath, 'package']);
    }
    finally {
        yield del(projectPaths_1.vscodeignorePath);
    }
}));
Пример #16
0
 fs.readdirSync(source).forEach((entry) => {
   const fullPathSource = path.join(source, entry);
   const fullPathTarget = path.join(target, entry);
   const stats = fs.statSync(fullPathSource);
   if (stats.isDirectory()) {
     copyDir(fullPathSource, fullPathTarget);
   } else {
     fs.copyFileSync(fullPathSource, fullPathTarget);
   }
 });
Пример #17
0
gulp.task('vsix:offline:package', () => __awaiter(this, void 0, void 0, function* () {
    del.sync(projectPaths_1.vscodeignorePath);
    fs.copyFileSync(projectPaths_1.offlineVscodeignorePath, projectPaths_1.vscodeignorePath);
    try {
        yield doPackageOffline();
    }
    finally {
        del(projectPaths_1.vscodeignorePath);
    }
}));
Пример #18
0
				proc.on('exit', function(code) {
					try {
						if(code !== 0) {
							callback(new Error(`Transpile failed: ${data}`));
							return;
						}

						const src_info = path.parse(src_path);

						let target_dir = path.join(src_info.dir, '__target__');
						let source = fs.readFileSync(path.join(target_dir, src_info.name + '.js'), 'utf8');
						let sourcemap = fs.readFileSync(path.join(target_dir, src_info.name + '.map'), 'utf8');
						let output_dir = path.join(rootContext, 'transcrypt');

						if(!fs.existsSync(output_dir)) {
							fs.mkdirSync(output_dir);
						}

						fs.copyFileSync(
							path.join(target_dir, 'org.transcrypt.__runtime__.js'),
							path.join(output_dir, 'org.transcrypt.__runtime__.js')
						);

						let files = fs.readdirSync(target_dir);
						// __target__ should never have directories, but sanity check just in case
						let clear = true;

						for(let i = 0; i < files.length; i++) {
							let fn = path.join(target_dir, files[i]);
							let stat = fs.lstatSync(fn);

							if(!stat.isDirectory()) {
								fs.unlinkSync(fn);
							} else {
								clear = false;
							}
						}

						if(clear)
							fs.rmdirSync(target_dir);

						sourcemap = JSON.parse(sourcemap);

						// webpack requires that the source code be included in the sourcemap...
						if(sourcemap.sourcesContent === undefined) {
							sourcemap['sourcesContent'] = [source_in]
						}

						sourcemap = JSON.stringify(sourcemap);

						callback(null, source, sourcemap);
					} catch(err) {
						callback(err);
					}
				});
Пример #19
0
 files.forEach(file => {
     const src = path.resolve(file.replace('vendor/', 'node_modules/'));
     const dest = path.resolve(`./dist/${browser}/${file}`);
     if (fs.existsSync(src) && !fs.existsSync(dest)) {
         //$.log.info(`Copying "${src}" to "${dest}"`);
         if (!fs.existsSync(path.dirname(dest))) {
             fs.mkdirSync(path.dirname(dest), { 'recursive': true });
         }
         fs.copyFileSync(src, dest);
     }
 });
Пример #20
0
function copyFile (srcStat, src, dest, opts) {
  if (typeof fs.copyFileSync === 'function') {
    fs.copyFileSync(src, dest)
    fs.chmodSync(dest, srcStat.mode)
    if (opts.preserveTimestamps) {
      return utimesSync(dest, srcStat.atime, srcStat.mtime)
    }
    return
  }
  return copyFileFallback(srcStat, src, dest, opts)
}
Пример #21
0
 datastorepaths.forEach( ( dspath: string ) => {
   if( !fs.existsSync( dspath ) ) {
     // copy from local resources
     // into target db path
     const dsfilename = path.basename( dspath );
     fs.copyFileSync(
       path.join( __dirname, 'resources/databases', dsfilename ),
       dspath
     );
   }
 });
Пример #22
0
 it('should set headers and footers infos', function (done) {
   const archiveBase = `${mockDir}/DirNew/ExtArchive.7z`
   const archive = `${tmpDir}/list-header-footer.7z`
   copyFileSync(archiveBase, archive)
   const seven = list(archive, { recursive: true })
   seven.on('end', function () {
     expect(seven.info.get('Physical Size')).to.equal('290')
     expect(seven.info.get('Type')).to.equal('7z')
     done()
   })
 })
    fs.readdirSync(dir).forEach(it => {
        const itsPath = path.resolve(dir, it);
        const itsStat = fs.statSync(itsPath);

        if (itsStat.isDirectory()) {
            copyToRawRecursive(itsPath);
        } else if (dir !== "src/samples") {
            if ((itsPath.endsWith(".html") || itsPath.endsWith(".ts") || itsPath.endsWith(".css") || itsPath.endsWith(".md")) && !itsPath.endsWith("index.ts")) {
                fs.copyFileSync(itsPath, itsPath + ".raw");
            }
        }
    })
Пример #24
0
	copyFile(source, destination, mapping) {
		if (mapping) {
			var buffer = FS.readFileSync(source).toString();
			mapping.forEach(function(map) {
				var regex = new RegExp(map.key, "g");
				buffer = buffer.replace(regex, map.value);
			});
			FS.writeFileSync(destination, buffer);
		}
		else
			FS.copyFileSync(source, destination);
	}
Пример #25
0
gulp.task('dist', (cb) => {
  let cbs = 0;
  fs.copyFileSync('./src/template7.d.ts', './dist/template7.d.ts');
  umd(() => {
    cbs += 1;
    if (cbs === 2) cb();
  });
  es(() => {
    cbs += 1;
    if (cbs === 2) cb();
  });
});
Пример #26
0
    test('creates files', (done) => {
        /* test svg icon processing */
        if (process.env.TEMPLATE === 'web-app') {
            fs.copyFileSync(
                path.join(__dirname, '../img/babel.svg'),
                path.join(tempDir, 'src/scss/bg-svg-icons/babel.svg'),
            );
        }

        assert.file([
            'package.json',
            'Gruntfile.js',
            'grunt/aliases.js',
            'grunt/config/twigRender.js',
            'src/js/_main.js',
            'src/js/app.js',
            'src/components/sample/Sample.jsb.js',
            'src/components/slider/Slider.jsb.js',
            'src/components/select/Select.jsb.js',
            'src/components/dialog/Dialog.jsb.js',
            'src/scss/styles.scss',
            'src/scss/blocks/_header.scss',
            'src/scss/blocks/_footer.scss',
            'src/html/pages/index.twig',
            'static/img/appicons/favicon.ico',
        ]);

        assert.noFile(['src/scss/mixins/_clearfix.scss']);

        assert.fileContent([
            ['src/components/sample/Sample.jsb.js', /lodash-es/],
            ['src/components/sample/Sample.jsb.js', /date-fns\/esm/],
        ]);

        if (process.env.TEMPLATE === 'web-app') {
            jest.setTimeout(buildTimeout);

            buildApp(() => {
                /* test svg icon processing */
                assert.file([
                    'src/scss/bg-svg-icons/babel.svg',
                    'tmp/svg-bgs/babel.svg',
                    'tmp/svg-scss/_svg-icon-map.scss',
                ]);

                assert.fileContent([['tmp/svg-scss/_svg-icon-map.scss', /babel:/]]);

                done();
            });
        } else {
            done();
        }
    });
Пример #27
0
    it('should have copy in buh62 folder', (done) => {
        let targetFile =  path.join('C:\\avpsoft\\buh62\\models\\', modelForExport + '.xml');
        let copyFile =  path.join('C:\\avpsoft\\buh70\\models\\', modelForExport + '_copy.xml');
        expect(fs.existsSync(sourceFile)).toBeTruthy();
        fs.copyFileSync(sourceFile, copyFile);
        expect(fs.existsSync(copyFile)).toBeTruthy();

        fs.rename(copyFile, targetFile,(err) => {
            if (err) throw err;
            expect(fs.existsSync(targetFile)).toBeTruthy();
            done();
        });
    })
Пример #28
0
 it('can be required if electron.exe is renamed', () => {
   const { execPath } = remote.process
   const testExecPath = path.join(path.dirname(execPath), 'test.exe')
   fs.copyFileSync(execPath, testExecPath)
   try {
     const fixture = path.join(fixtures, 'module', 'echo-renamed.js')
     assert.ok(fs.existsSync(fixture))
     const child = require('child_process').spawnSync(testExecPath, [fixture])
     assert.strictEqual(child.status, 0)
   } finally {
     fs.unlinkSync(testExecPath)
   }
 })
Пример #29
0
 arrayCopy.forEach((file, i, arr) => {
   CaptnM.log(verbose, `copying from ${file.src} to ${file.dest}`);
   try {
     mkdirp.sync(path.dirname(file.dest));
     fs.copyFileSync(file.src, file.dest);
   } catch (e) {
     CaptnM.logError(e);
     // we rely on the fact that once a forEach loop is initialised, the array
     // it is working with is 'frozen' and any changes to it will not affect
     // the loop
     arr.splice(i, 1);
   }
 });
Пример #30
0
 _moveTmpConfig() {
   if (fs.copyFileSync && fs.constants.COPYFILE_FICLONE) {
     // Node v8.5.0+ can use a copy-on-write reflink
     fs.copyFileSync(
       this.tmpConfigPath,
       this.configPath,
       fs.constants.COPYFILE_FICLONE
     )
   } else {
     // Fallback for old node versions
     fse.copySync(this.tmpConfigPath, this.configPath)
   }
   fse.unlinkSync(this.tmpConfigPath)
 }