How to use the fs-jetpack.list function in fs-jetpack

To help you get started, we’ve selected a few fs-jetpack examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WeebDev / lolisafe / src / api / routes / uploads / chunksPOST.js View on Github external
url: `${process.env.DOMAIN}/`
		};

		for (const chunk of req.body.files) {
			const { uuid, count } = chunk;
			// console.log('Chunk', chunk);

			const chunkOutput = path.join(__dirname,
				'..',
				'..',
				'..',
				'..',
				process.env.UPLOAD_FOLDER,
				'chunks',
				uuid);
			const chunkDir = await jetpack.list(chunkOutput);
			const ext = path.extname(chunkDir[0]);
			const output = path.join(__dirname,
				'..',
				'..',
				'..',
				'..',
				process.env.UPLOAD_FOLDER,
				`${filename}${ext || ''}`);
			chunkDir.sort();

			// Save some data
			info.name = `${filename}${ext || ''}`;
			info.url += `${filename}${ext || ''}`;

			for (let i = 0; i < chunkDir.length; i++) {
				const dir = path.join(__dirname,
github Leo501 / CocosCreatorTutorial / HotUpdateDemo / tools / version_generator.js View on Github external
function copyDirSync(path, dest) {
    let flist = jetpack.list(path)
    for (let i = 0; i < flist.length; i++) {
        let absolutePath = `${path}/${flist[i]}`
        if (jetpack.exists(absolutePath) == "file") { // 是文件则复制
            jetpack.copy(absolutePath, `${dest}/${flist[i]}`, {
                overwrite: true
            });
        }
        if (jetpack.exists(absolutePath) == "dir") { // 是目录则递归
            copyDirSync(absolutePath, `${dest}/${flist[i]}`)
        }
    }
}
github z-edit / zedit / src / javascripts / helpers / fileHelpers.js View on Github external
fh.deleteEmptyFolders = function(folder) {
    let canDelete = true;
    jetpack.list(folder).forEach(filename => {
        let filePath = fh.path(folder, filename),
            isDir = jetpack.exists(filePath) === 'dir';
        canDelete = isDir && fh.deleteEmptyFolders(filePath) && canDelete;
    });
    if (canDelete) jetpack.remove(folder);
    return canDelete;
};
github etherisc / tokensale / bin / select-resources.js View on Github external
function selectResources(dir, resources) {

    if (!fs.exists(dir)) {

        fs.dir(dir);

    }

    fs.list(dir)
        .filter(file => file !== '.keep')
        .forEach(file => fs.remove(`${dir}/${file}`));

    if (resources && resources.length) {

        resources.forEach((file) => {

            const src = path.resolve(`${dir}-available/${file}`);
            const dest = path.resolve(`${dir}/${file}`);

            if (fs.exists(src)) {

                fs.symlink(src, dest);
                log.info(`Selected ${dir}: ${dir}/${file}`);

            } else {