Skip to content

Commit

Permalink
Change artifact name + rimraf-promise
Browse files Browse the repository at this point in the history
  • Loading branch information
KoltesDigital committed Aug 8, 2017
1 parent d3faca0 commit ab1c8de
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 45 deletions.
31 changes: 12 additions & 19 deletions app/browser/app/shadertoy/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { spawn } = require('child_process');
const fs = require('fs');
const makeDir = require('make-dir');
const { join } = require('path');
const rimraf = require('rimraf');
const rimraf = require('rimraf-promise');

export default ['$rootScope', ($rootScope) => {
let iframe = null;
Expand Down Expand Up @@ -225,28 +225,21 @@ export default ['$rootScope', ($rootScope) => {

logs.length = 0;

async function createDirectory() {
++pendingProcesses;
logs.push('Making directory ' + options.directory);
await makeDir(options.directory);
return $rootScope.$apply(() => {
--pendingProcesses;
return actualExport(options);
});
}

if (options.cleanDirectoryBeforehand) {
++pendingProcesses;
logs.push('Cleaning directory ' + options.directory);
return rimraf(join(options.directory, '*'), (err) => {
if (err) throw err;
++pendingProcesses;
logs.push('Creating directory ' + options.directory);
makeDir(options.directory)
.then(() => {
if (options.cleanDirectoryBeforehand) {
logs.push('Cleaning directory ' + options.directory);
return rimraf(join(options.directory, '*'));
}
})
.then(() => {
return $rootScope.$apply(() => {
--pendingProcesses;
return createDirectory();
return actualExport(options);
});
});
} else
return createDirectory();
},
isExporting: () => {
return pendingProcesses > 0;
Expand Down
13 changes: 0 additions & 13 deletions app/package.json

This file was deleted.

13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@
],
"scripts": {
"build": "node scripts/build.js",
"postinstall": "jspm install && electron-builder install-app-deps",
"postinstall": "jspm install",
"start": "electron ."
},
"dependencies": {
"electron-store": "^1.2.0",
"make-dir": "^1.0.0",
"rimraf": "^2.6.1",
"rimraf-promise": "^2.0.0"
},
"devDependencies": {
"del": "^3.0.0",
"electron": "^1.6.11",
"electron-builder": "^19.19.1",
"electron-store": "^1.2.0",
Expand All @@ -45,6 +50,7 @@
},
"build": {
"appId": "digital.koltes.shadertoy-exporter",
"artifactName": "${name}-${version}-${arch}.${ext}",
"directories": {
"app": "app"
},
Expand All @@ -60,6 +66,9 @@
"dmg"
]
},
"nsis": {
"artifactName": "${name}-setup-${version}-${arch}.${ext}"
},
"productName": "Shadertoy Exporter",
"win": {
"target": [
Expand Down
38 changes: 27 additions & 11 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
'use strict';

const del = require('del');
const { build, Platform } = require('electron-builder');
const { writeFile } = require('fs');
const { bundleSFX } = require('jspm');
const makeDir = require('make-dir');
const { join, resolve } = require('path');
const copyFile = require('quickly-copy-file');
const rimraf = require('rimraf-promise');

const { build: buildOptions } = require('../package.json');
const packageJson = require('../package.json');
const buildOptions = packageJson.build;
buildOptions.directories.app = 'bundle';

delete packageJson.build;
delete packageJson.devDependencies;
delete packageJson.jspm;
delete packageJson.scripts;
packageJson.main = 'main.js';

const rootPath = resolve(__dirname, '..');

function copyFiles(files) {
return Promise.all(files.map(pair => copyFile(pair[0], pair[1])));
}

console.log('Removing build directories');
del([
join(rootPath, 'bundle'),
join(rootPath, 'dist'),
console.log('Cleaning build directories');
return Promise.all([
rimraf(join(rootPath, 'bundle', '*')),
rimraf(join(rootPath, 'dist', '*')),
])
.then(() => {
console.log('Copying files');
console.log('Copying files to bundle');
return copyFiles([
[
join(rootPath, 'app', 'package.json'),
join(rootPath, 'bundle', 'package.json'),
],
[
join(rootPath, 'app', 'main.js'),
join(rootPath, 'bundle', 'main.js'),
Expand All @@ -37,6 +42,17 @@ del([
],
]);
})
.then(() => {
console.log('Generating bundle/package.json');
return new Promise((resolve, reject) => {
return writeFile(join(rootPath, 'bundle', 'package.json'), JSON.stringify(packageJson), (err) => {
if (err)
return reject(err);
else
return resolve();
});
});
})
.then(() => {
console.log('Bundling JSPM app');
return bundleSFX('app/main.js', join(rootPath, 'bundle', 'browser', 'app.js'), {
Expand Down

0 comments on commit ab1c8de

Please sign in to comment.