-
Notifications
You must be signed in to change notification settings - Fork 23
/
figma_download_files_by_list.js
53 lines (42 loc) · 1.39 KB
/
figma_download_files_by_list.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/node
const {readSettings, open, login, downloadFile, close} = require('./figma_actions')
let figmaLogin = '';
let figmaPassword = '';
let figmaFilesListFile = '';
const fs = require('fs');
process.argv.forEach((arg) => {
const keyValue = arg.split("=");
switch (keyValue[0]) {
case 'figmaLogin':
figmaLogin = keyValue[1];
break;
case 'figmaPassword':
figmaPassword = keyValue[1];
break;
case 'figmaFilesList':
figmaFilesListFile = keyValue[1];
break;
}
});
if (!figmaLogin || !figmaPassword)
{
console.log('Usage: <script_name> <figma_login> <figma_password> <figmaFilesList>');
process.exit(1);
}
(async() => {
let figmaFilesList;
fs.readFile(figmaFilesListFile, (err, data) => {
if(err) throw err;
figmaFilesList = JSON.parse(data);
});
const settings = readSettings();
const session = await open(settings);
session.figmaLogin = figmaLogin;
session.figmaPassword = figmaPassword;
await login(session, settings);
for(let i = 0; i < figmaFilesList.length; i++) {
const dwResult = await downloadFile(session, figmaFilesList[i], settings);
console.log('download ('+(i+1)+'/'+figmaFilesList.length+') ' + figmaFilesList[i].key + ', ' + figmaFilesList[i].file + ' result: ' + dwResult);
}
close(session);
})();