Skip to content

Instantly share code, notes, and snippets.

@peterflynn
Created October 15, 2018 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterflynn/5eb77db4b5d4a626bf8087a0498c94ce to your computer and use it in GitHub Desktop.
Save peterflynn/5eb77db4b5d4a626bf8087a0498c94ce to your computer and use it in GitHub Desktop.
var fs = require("uxp").storage.localFileSystem;
function loadStyleguideFile(selection) {
return fs.getFileForOpening()
.then(function (file) {
console.log("User chose file: " + file);
return file.read();
})
.then(function (text) {
var json = JSON.parse(text);
createFrame(selection, json.padding.vertical, json.padding.horizontal);
});
}
{
"padding": {
"horizontal": 10,
"vertical": 10
}
}
var fs = require("uxp").storage.localFileSystem;
async function loadStyleguideFile(selection) {
var file = await fs.getFileForOpening();
console.log("User chose file: " + file);
var text = await file.read();
var json = JSON.parse(text);
createRectangle(selection, json.padding.vertical, json.padding.horizontal);
}
var fs = require("uxp").storage.localFileSystem;
async function loadStyleguideFile(selection) {
var file = await fs.getFileForOpening();
if (!file) {
return; // picker was canceled
}
console.log("User chose file: " + file);
var text = await file.read();
var json = JSON.parse(text);
createRectangle(selection, json.padding.vertical, json.padding.horizontal);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment