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

Tmp dir naming #262

Closed
joliss opened this issue May 24, 2015 · 5 comments
Closed

Tmp dir naming #262

joliss opened this issue May 24, 2015 · 5 comments

Comments

@joliss
Copy link
Member

joliss commented May 24, 2015

/cc @rwjblue, @stefanpenner, @caitp

When tmp dir handling is centralized, what do we want the names of the temporary directories to be?

Currently we have names like babel-tmp_dest_dir-kbIdaoyR.tmp, which isn't terribly user-friendly.

Are we going to do something like this (numbered by order of execution), or should we try to put more information into the names?

01-babel
02-babel
03-babel
04-babel
05-sass
06-sass
07-funnel
08-jshint
09-merge-trees
10-merge-trees
11-merge-trees

If we wanted to put more information (like 01-babel-lib, 02-babel-vendor), it would likely have to be supplied by the build definition (like Brocfile.js or ember-app.js). I have no idea whether this is doable in practice. But if we plan on doing this, I'd like to take it into account for the API.

Semi-relatedly, currently everything is in ./tmp, but we likely want to change this. I'm thinking maybe /tmp/broccoli.$PID/trees/01-babel for the output directory of the first plugin, and /tmp/broccoli.$PID/caches/01-babel for its cache directory. Alternatively, we could use /tmp/broccoli.$PID/01-babel/{out,cache}, and create symlinks at /tmp/broccoli.$PID/01-babel/in-{0,1,2,3,4,5} pointing to the input directories; those symlinks would not be used by Broccoli, but created for the convenience of people inspecting the tmp dirs.

@caitp
Copy link

caitp commented May 24, 2015

Ordering the temp directories by use order would work well for us. We don't care a whole lot about tracking the pid as we clean the temp dir when killing gulp. Just naming the temp dirs something more informative would be a bit nicer. @IgorMinar has more insight into the angular use case, so cc-ing him

@cecchi
Copy link

cecchi commented Jun 5, 2015

Somewhat related: Should we consider a different name for the temporary directory itself? I could imagine a case where a project has an existing tmp/ directory. Would renaming to .broc/ or .broccoli/ make sense?

@joliss
Copy link
Member Author

joliss commented Jun 6, 2015

@cecchi, yes, unless there are unforeseen issues with this, we'll likely use the system /tmp dir when available (and it would be configurable as well).

@stefanpenner
Copy link
Contributor

  • these names seem much more friendly.
  • we should work hard to make tmp dir configurable

@stefanpenner
Copy link
Contributor

broccoli 1.x has this

broccoli/lib/builder.js

Lines 272 to 292 in 0bc034c

// Create temporary directory, like
// /tmp/broccoli-9rLfJh/out-067-merge_trees_vendor_packages
// type is 'out' or 'cache'
mkTmpDir(nodeWrapper, type) {
let nameAndAnnotation =
nodeWrapper.nodeInfo.name + ' ' + (nodeWrapper.nodeInfo.annotation || '');
// slugify turns fooBar into foobar, so we call underscored first to
// preserve word boundaries
let suffix = underscoreString.underscored(nameAndAnnotation.substr(0, 60));
suffix = underscoreString.slugify(suffix).replace(/-/g, '_');
// 1 .. 147 -> '001' .. '147'
const paddedId = underscoreString.pad(
'' + nodeWrapper.id,
('' + this.nodeWrappers.length).length,
'0'
);
const dirname = type + '-' + paddedId + '-' + suffix;
const tmpDir = path.join(this.builderTmpDir, dirname);
fs.mkdirSync(tmpDir);
return tmpDir;
}

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

4 participants