Skip to content

Commit 732db4c

Browse files
authored
fix: honor skipSubdirectories in project config (#1117)
Read skipSubdirectories from .clasp.json when initializing file options. This fixes clasp push behavior where subdirectories should be skipped but were always included due to a mismatched config key. Add a regression test that enables skipSubdirectories and verifies nested files are not collected.
1 parent 1ec479b commit 732db4c

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

src/core/clasp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export async function initClaspInstance(options: InitOptions): Promise<Clasp> {
198198
ignorePatterns: ignoreRules,
199199
filePushOrder: filePushOrder,
200200
fileExtensions: fileExtensions,
201-
skipSubdirectories: config.ignoreSubdirectories,
201+
skipSubdirectories: config.skipSubdirectories ?? false,
202202
},
203203
project: {
204204
scriptId: config.scriptId,

test/core/files.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,46 @@ describe('File operations', function () {
225225
});
226226
});
227227

228+
// Test suite for projects where `skipSubdirectories` is enabled in .clasp.json.
229+
describe('with valid project, skipSubdirectories enabled', function () {
230+
beforeEach(function () {
231+
mockfs({
232+
'appsscript.json': mockfs.load(path.resolve(__dirname, '../fixtures/appsscript-no-services.json')),
233+
'Code.js': mockfs.load(path.resolve(__dirname, '../fixtures/Code.js')),
234+
'subdir/Code.js': mockfs.load(path.resolve(__dirname, '../fixtures/Code.js')),
235+
'page.html': mockfs.load(path.resolve(__dirname, '../fixtures/page.html')),
236+
'.clasp.json': JSON.stringify(
237+
{
238+
scriptId: 'mock-script-id',
239+
skipSubdirectories: true,
240+
},
241+
null,
242+
2,
243+
),
244+
'package.json': '{}',
245+
'node_modules/test/index.js': '',
246+
[path.resolve(os.homedir(), '.clasprc.json')]: mockfs.load(
247+
path.resolve(__dirname, '../fixtures/dot-clasprc-authenticated.json'),
248+
),
249+
});
250+
});
251+
252+
it('should not collect files from subdirectories', async function () {
253+
const clasp = await initClaspInstance({
254+
credentials: mockCredentials(),
255+
});
256+
const foundFiles = await clasp.files.collectLocalFiles();
257+
const foundFilePaths = foundFiles.map(file => file.localPath);
258+
259+
expect(foundFilePaths).to.not.include(path.normalize('subdir/Code.js'));
260+
expect(foundFiles).to.have.length(3);
261+
});
262+
263+
afterEach(function () {
264+
mockfs.restore();
265+
});
266+
});
267+
228268
// Test suite for scenarios where the local project setup is invalid (e.g., missing .clasp.json),
229269
// even if the user is authenticated. Most operations should fail.
230270
describe('with invalid project, authenticated', function () {

0 commit comments

Comments
 (0)