Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing Export Templates not working on Windows #171

Open
schaa0 opened this issue Sep 26, 2016 · 2 comments
Open

Installing Export Templates not working on Windows #171

schaa0 opened this issue Sep 26, 2016 · 2 comments

Comments

@schaa0
Copy link

schaa0 commented Sep 26, 2016

  • Operating system: Windows 10
  • Pencil version: 3.0.0-rc.1
ExportTemplateManager.installTemplateFromFile = function (file, type , callback) {
    console.log("begin install template, from file : " + file);
    var readStream = fs.createReadStream(file.toString());
    var targetDir = ExportTemplateManager.getUserTemplateDirectory().toString();
    targetDir = targetDir.concat("/"+type);
    var index = readStream.path.lastIndexOf("/"); // <--- Windows is using backslash as path separator!!
    var fileName = readStream.path.substring(index + 1);  // index is always -1 on Windows
    targetDir = targetDir.concat("/" + fileName.replace(/\.[^\.]+$/, "") + "_" + Math.ceil(Math.random() * 1000) + "_" + (new Date().getTime()));
    readStream
    .pipe(unzip.Extract({path: targetDir}))
    .on("entry", function (entry) {
        var stat = fs.statSync(targetDir);
        if(!stat || !stat.isDirectory()) {
            fs.mkdirSync(targetDir);
        }
    })
@sparkercsu
Copy link

I have found this issue too. Is there a way to manually add templates? Probably not.

srottem added a commit to srottem/pencil that referenced this issue Jun 26, 2017
@abicelis
Copy link

Tested commit #9295ba4.
Works perfectly on Win10.

Thanks @srottem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants