Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// check if we are ignoring this file
if ((isDir && ignoreRootDirs && ignoreRootDirs.indexOf(filename) !== -1) || (isDir ? ignoreDirs : ignoreFiles).test(filename)) {
_t.logger.debug(__('Ignoring %s', from.cyan));
return next();
}
// if this is a directory, recurse
if (isDir) {
return recursivelyCopy.call(_t, from, path.join(destDir, filename), null, opts, next);
}
// we have a file, now we need to see what sort of file
// if the destination directory does not exists, create it
fs.ensureDirSync(destDir);
var ext = filename.match(extRegExp);
switch (ext && ext[1]) {
case 'css':
// if we encounter a css file, check if we should minify it
if (_t.minifyCSS) {
_t.logger.debug(__('Copying and minifying %s => %s', from.cyan, to.cyan));
fs.readFile(from, function (err, data) {
if (err) {
throw err;
}
fs.writeFile(to, cleanCSS.process(data.toString()), next);
});
} else {
copyFile.call(_t, from, to, next);
fs.outputFileSync(path.join(options.to, exporter.sysdir() + '-resources', 'files.json'), JSON.stringify({ files: files }, null, '\t'));
}
for (let callback of ProjectFile_1.Callbacks.preHaxeCompilation) {
callback();
}
if (options.onlydata) {
log.info('Exporting only data.');
// We need to copy assets into project folder for Android native
if (exporter.sysdir() === 'android-native') {
// Location of preprocessed assets
let dataDir = path.join(options.to, exporter.sysdir());
// Use the same 'safename' as kincmake
let safename = project.name.replace(/ /g, '-');
let assetsDir = path.resolve(buildDir, safename, 'app', 'src', 'main', 'assets');
// Create path if it does not exist (although it should)
fs.ensureDirSync(assetsDir);
log.info(assetsDir);
fs.copySync(path.resolve(dataDir), assetsDir);
}
return project.name;
}
else {
return await exportProjectFiles(project.name, path.join(options.to, exporter.sysdir() + '-resources'), options, exporter, kore, korehl, project.icon, project.libraries, project.targetOptions, project.defines, project.cdefines, project.stackSize, project.version, project.id);
}
}
function isKhaProject(directory, projectfile) {
options.addFileCallback = options.addFileCallback || function (fullPathSrc, fullPathDest) {
log('File addition synced ' + fullPathDest);
};
// 删除文件时输出到控制台的默认 callback
options.deleteFileCallback = options.deleteFileCallback || function (fullPathSrc, fullPathDest) {
log('File deletion synced ' + fullPathDest);
};
// 修改文件时输出到控制台的默认 callback
options.updateFileCallback = options.updateFileCallback || function (fullPathSrc, fullPathDest) {
log('File modification synced ' + fullPathDest);
};
// 检查目标目录是否存在,如果目标目录不存在则创建一个,如果目标目录不存在而直接写入文件则会 crash
fs.ensureDirSync(dest);
remove(options, src, dest);
add(options, src, dest);
};
logger.log.init = function (callback) {
var platform = ti.resolvePlatform(cli.argv.platform),
buildDir = path.join(cli.argv['project-dir'], 'build');
logger.fileWriteEnabled = true;
fs.ensureDirSync(buildDir, 0o766);
// create our write stream
logger.log.filestream = fs.createWriteStream(path.join(buildDir, 'build_' + platform + '.log'), { flags: 'w', encoding: 'utf8', mode: 0o666 });
function styleHeading(s) {
return ('' + s).bold;
}
function styleValue(s) {
return ('' + s).magenta;
}
function rpad(s) {
return appc.string.rpad(s, 27);
}
it('should print out information in verbose mode', () => {
ensureDirSync('test/data/output/dist');
return run(
'--config', 'test/data/config/cli/no-compiler.json',
'--source', 'test/data/input/*.feature',
'--base', 'test/data/input',
'--destination', 'test/data/output/dist',
'--verbose'
).then(cli => {
expect(cli.sources.length).to.be.above(0);
}, fail);
});
});
function createApp(
name,
verbose,
version,
useNpm,
usePnp,
useTypescript,
template
) {
const root = path.resolve(name);
const appName = path.basename(root);
checkAppName(appName);
fs.ensureDirSync(name);
if (!isSafeToCreateProjectIn(root, name)) {
process.exit(1);
}
console.log(`Creating a new React app in ${chalk.green(root)}.`);
console.log();
const packageJson = {
name: appName,
version: '0.1.0',
private: true,
};
fs.writeFileSync(
path.join(root, 'package.json'),
JSON.stringify(packageJson, null, 2) + os.EOL
);
async function create(opts = {}) {
if (!opts.name) {
throw new Error('name argument required')
return
}
if (!opts.template) {
throw new Error('template argument required')
return
}
const dirname = path.resolve(opts.name)
const name = path.basename(dirname)
const [ user, repo, ...paths ] = opts.template.split('/')
fs.ensureDirSync(name)
getTar(Object.assign({}, opts, {
name,
user,
repo,
paths,
}))
const templatePkg = require(
path.join(dirname, 'package.json')
)
const pkg = Object.assign({}, templatePkg, {
name,
version: '1.0.0',
})
const fs = require('fs-extra');
const fsExtra = require('fs-extra');
const path = require('path');
fsExtra.ensureDirSync('public');
fs.copySync(
path.resolve(process.cwd(), 'src/assets/favicons'),
path.resolve(process.cwd(), 'public')
);
function ensureFolderStructure(){
let sysAWSMobileJSDirPath = pathManager.getSysAWSMobileJSDirPath()
let sysProjectAWSConfigDirPath = pathManager.getSysProjectAWSConfigDirPath()
fs.ensureDirSync(sysAWSMobileJSDirPath)
fs.ensureDirSync(sysProjectAWSConfigDirPath)
}